summaryrefslogtreecommitdiffstats
path: root/tools/patman
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2013-05-08 08:06:08 +0000
committerTom Rini <trini@ti.com>2013-05-14 15:37:58 -0400
commitcce717a96c5840b0cf33e30c87fb1f2b8d633ee3 (patch)
tree8f40b0ed3d2f908abf140ece6d48280e3dfcf216 /tools/patman
parent2a08b740e39d618f9428cfdcf8e1caa7239bcb8f (diff)
downloadblackbird-obmc-uboot-cce717a96c5840b0cf33e30c87fb1f2b8d633ee3.tar.gz
blackbird-obmc-uboot-cce717a96c5840b0cf33e30c87fb1f2b8d633ee3.zip
buildman: Produce a sensible error message when branch is missing
Rather than a backtrace, produce a nice error message when an invalid branch is provided to buildman. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/patman')
-rw-r--r--tools/patman/gitutil.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index e31da1548d..b7f6739552 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -56,10 +56,14 @@ def GetUpstream(git_dir, branch):
Returns:
Name of upstream branch (e.g. 'upstream/master') or None if none
"""
- remote = command.OutputOneLine('git', '--git-dir', git_dir, 'config',
- 'branch.%s.remote' % branch)
- merge = command.OutputOneLine('git', '--git-dir', git_dir, 'config',
- 'branch.%s.merge' % branch)
+ try:
+ remote = command.OutputOneLine('git', '--git-dir', git_dir, 'config',
+ 'branch.%s.remote' % branch)
+ merge = command.OutputOneLine('git', '--git-dir', git_dir, 'config',
+ 'branch.%s.merge' % branch)
+ except:
+ return None
+
if remote == '.':
return merge
elif remote and merge:
@@ -78,9 +82,11 @@ def GetRangeInBranch(git_dir, branch, include_upstream=False):
branch: Name of branch
Return:
Expression in the form 'upstream..branch' which can be used to
- access the commits.
+ access the commits. If the branch does not exist, returns None.
"""
upstream = GetUpstream(git_dir, branch)
+ if not upstream:
+ return None
return '%s%s..%s' % (upstream, '~' if include_upstream else '', branch)
def CountCommitsInBranch(git_dir, branch, include_upstream=False):
@@ -90,9 +96,12 @@ def CountCommitsInBranch(git_dir, branch, include_upstream=False):
git_dir: Directory containing git repo
branch: Name of branch
Return:
- Number of patches that exist on top of the branch
+ Number of patches that exist on top of the branch, or None if the
+ branch does not exist.
"""
range_expr = GetRangeInBranch(git_dir, branch, include_upstream)
+ if not range_expr:
+ return None
pipe = [['git', '--git-dir', git_dir, 'log', '--oneline', '--no-decorate',
range_expr],
['wc', '-l']]
OpenPOWER on IntegriCloud