From 8850545f853d0b30212b37be6be0f1e47704122d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sat, 29 May 2010 20:05:28 +0200 Subject: Simplify Git build version detection. diff --git a/BuildTools/SCons/Version.py b/BuildTools/SCons/Version.py index 0ff1531..401df21 100644 --- a/BuildTools/SCons/Version.py +++ b/BuildTools/SCons/Version.py @@ -1,16 +1,10 @@ import subprocess, os, datetime def getGitBuildVersion(project) : - headVersion = git("rev-parse HEAD") - if headVersion : - tags = git("tag --contains HEAD -l " + project + "-*") - if len(tags) > 0 : - for tag in tags.split("\n") : - tagVersion = git("rev-parse " + tag + "^{commit}") - if tagVersion == headVersion : - return tag[len(project)+1:] - return None - + tag = git("describe --tags --exact --match " + project + "-*") + if tag : + return tag.rstrip()[len(project)+1:] + def git(cmd) : p = subprocess.Popen("git " + cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=(os.name != "nt")) gitVersion = p.stdout.read() -- cgit v0.10.2-6-g49f6