From 35c4473375fa0e80b22bae04618089f7365da934 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 2 Sep 2015 23:22:17 +0000 Subject: [PATCH] improve error reporting collect stderr and report it when some of the git query commands fail Change-Id: I2bcabec71518e32416581f2d0107c45c69795bd3 --- openstack_releases/gitutils.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/openstack_releases/gitutils.py b/openstack_releases/gitutils.py index 87eeae6cab..3091dbdcd2 100644 --- a/openstack_releases/gitutils.py +++ b/openstack_releases/gitutils.py @@ -72,21 +72,29 @@ def sha_for_tag(workdir, repo, version): actual_sha = subprocess.check_output( ['git', 'log', str(version), '-n', '1', '--pretty=format:%H'], cwd=os.path.join(workdir, repo), + stderr=subprocess.STDOUT, ) actual_sha = actual_sha.strip() - except subprocess.CalledProcessError: + except subprocess.CalledProcessError as e: + print('ERROR getting SHA for tag %r: %s [%s]' % + (version, e, e.output.strip())) actual_sha = '' return actual_sha def check_ancestry(workdir, repo, old_version, sha): "Check if the SHA is in the ancestry of the previous version." - ancestors = subprocess.check_output( - ['git', 'log', '--oneline', '--ancestry-path', - '%s..%s' % (old_version, sha)], - cwd=os.path.join(workdir, repo), - ).strip() - return bool(ancestors) + try: + ancestors = subprocess.check_output( + ['git', 'log', '--oneline', '--ancestry-path', + '%s..%s' % (old_version, sha)], + cwd=os.path.join(workdir, repo), + stderr=subprocess.STDOUT, + ).strip() + return bool(ancestors) + except subprocess.CalledProcessError as e: + print('ERROR checking ancestry: %s [%s]' % (e, e.output.strip())) + return False def get_latest_tag(workdir, repo): @@ -94,6 +102,9 @@ def get_latest_tag(workdir, repo): return subprocess.check_output( ['git', 'describe', '--abbrev=0'], cwd=os.path.join(workdir, repo), + stderr=subprocess.STDOUT, ).strip() - except subprocess.CalledProcessError: + except subprocess.CalledProcessError as e: + print('WARNING failed to retrieve latest tag: %s [%s]' % + (e, e.output.strip())) return None