Skip to contentSkip to conversation

KVM Test: Utils - Handle git commit without tags

PATCH New Lucas Meneghel Rodrigues 1 participant 1 message Jan 25, 2010 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM Test: Utils - Handle git commit without tags

Sometimes the latest commit might not have any tags associated, leading to a failure on git describe. Let's handle this failure appropriately.

---
 client/tests/kvm/kvm_utils.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
client/tests/kvm/kvm_utils.py +5 -1
index df26a77..a6da832 100644
@@ -358,7 +358,11 @@ def get_git_branch(repository, branch, srcdir, commit=None, lbranch=None):
         utils.system("git checkout %s" % commit)
 
     h = utils.system_output('git log --pretty=format:"%H" -1')
-    desc = utils.system_output("git describe")
+    try:
+        desc = "tag %s" % utils.system_output("git describe")
+    except CmdError:
+        desc = "no tag found"
+
     logging.info("Commit hash for %s is %s (%s)" % (repository, h.strip(),
                                                     desc))
     return srcdir
Signature · 1 line
1.6.6