From 3fb55ea85139f2d29ce32f124d099419fbd06f60 Mon Sep 17 00:00:00 2001 From: Chad Miller Date: Tue, 23 Apr 2019 17:07:39 +0000 Subject: tools/read-version: handle errors When the cloned branch was not the canonical upstream and tags were not available, tox would fail because tools/read-version would fail, and tragically never print the advice that is in tools/read-version about how to fix it. This changes tools/read-version to catch the exception that is elsewhere explicitly thrown and treat that too as an error it can handle. --- tools/read-version | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tools/read-version') diff --git a/tools/read-version b/tools/read-version index e69c2ce0..6dca659e 100755 --- a/tools/read-version +++ b/tools/read-version @@ -71,9 +71,12 @@ if is_gitdir(_tdir) and which("git"): flags = ['--tags'] cmd = ['git', 'describe', '--abbrev=8', '--match=[0-9]*'] + flags - version = tiny_p(cmd).strip() + try: + version = tiny_p(cmd).strip() + except RuntimeError: + version = None - if not version.startswith(src_version): + if version is None or not version.startswith(src_version): sys.stderr.write("git describe version (%s) differs from " "cloudinit.version (%s)\n" % (version, src_version)) sys.stderr.write( -- cgit v1.2.3