← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~amzn-cmiller/cloud-init:read-version_errors into cloud-init:master

 

Chad has proposed merging ~amzn-cmiller/cloud-init:read-version_errors into cloud-init:master.

Requested reviews:
  cloud-init commiters (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~amzn-cmiller/cloud-init/+git/cloud-init/+merge/365126

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.
-- 
Your team cloud-init commiters is requested to review the proposed merge of ~amzn-cmiller/cloud-init:read-version_errors into cloud-init:master.
diff --git a/tools/read-version b/tools/read-version
index e69c2ce..6dca659 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(

Follow ups