diff options
author | Simon Glass <sjg@chromium.org> | 2020-10-29 21:46:34 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2020-11-05 09:11:31 -0700 |
commit | be051c0c7741d67f5093f6b61b64c45eb200235b (patch) | |
tree | edeac766a4773d11556b8092d9d7daa531f9252f /tools/patman/gitutil.py | |
parent | b3348522b753450be9e442452bf42aaa032d15d1 (diff) | |
download | u-boot-be051c0c7741d67f5093f6b61b64c45eb200235b.zip u-boot-be051c0c7741d67f5093f6b61b64c45eb200235b.tar.gz u-boot-be051c0c7741d67f5093f6b61b64c45eb200235b.tar.bz2 |
patman: Detect missing upstream in CountCommitsToBranch
At present if we fail to find the upstream then the error output is piped
to wc, resulting in bogus results. Avoid the pipe and check the output
directly.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/patman/gitutil.py')
-rw-r--r-- | tools/patman/gitutil.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index 27a0a9f..3a2366bc 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -66,9 +66,13 @@ def CountCommitsToBranch(branch): rev_range = '%s..%s' % (us, branch) else: rev_range = '@{upstream}..' - pipe = [LogCmd(rev_range, oneline=True), ['wc', '-l']] - stdout = command.RunPipe(pipe, capture=True, oneline=True).stdout - patch_count = int(stdout) + pipe = [LogCmd(rev_range, oneline=True)] + result = command.RunPipe(pipe, capture=True, capture_stderr=True, + oneline=True, raise_on_error=False) + if result.return_code: + raise ValueError('Failed to determine upstream: %s' % + result.stderr.strip()) + patch_count = len(result.stdout.splitlines()) return patch_count def NameRevision(commit_hash): |