From: Lucas Meneghel Rodrigues Subject: [PATCH] KVM Test: Utils - Handle git commit without tags Date: Mon, 25 Jan 2010 13:40:04 -0200 Message-ID: <1264434004-8958-1-git-send-email-lmr@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: autotest@test.kernel.org To: kvm@vger.kernel.org Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org Sometimes the latest commit might not have any tags associated, leading to a failure on git describe. Let's handle this failure appropriately. Signed-off-by: Lucas Meneghel Rodrigues --- client/tests/kvm/kvm_utils.py | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py index df26a77..a6da832 100644 --- a/client/tests/kvm/kvm_utils.py +++ b/client/tests/kvm/kvm_utils.py @@ -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 -- 1.6.6