diff options
author | Chad Miller <millchad@amazon.com> | 2019-04-23 17:07:39 +0000 |
---|---|---|
committer | Server Team CI Bot <josh.powers+server-team-bot@canonical.com> | 2019-04-23 17:07:39 +0000 |
commit | 3fb55ea85139f2d29ce32f124d099419fbd06f60 (patch) | |
tree | 63f926a8a0271ffbb0181f733b109250b2f84d27 /tools | |
parent | 5de83fc54c17b504842a924e7db08e8c2c1cebf9 (diff) | |
download | vyos-cloud-init-3fb55ea85139f2d29ce32f124d099419fbd06f60.tar.gz vyos-cloud-init-3fb55ea85139f2d29ce32f124d099419fbd06f60.zip |
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.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/read-version | 7 |
1 files changed, 5 insertions, 2 deletions
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( |