summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-05-29 18:05:28 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-05-29 18:05:51 (GMT)
commit8850545f853d0b30212b37be6be0f1e47704122d (patch)
tree2cf5f1cc89817ec9ef4ab23790c5939986e77eb7
parentbd7cc758641bec5b3cf9fc47a9c2b48082f943da (diff)
downloadswift-8850545f853d0b30212b37be6be0f1e47704122d.zip
swift-8850545f853d0b30212b37be6be0f1e47704122d.tar.bz2
Simplify Git build version detection.
-rw-r--r--BuildTools/SCons/Version.py14
1 files changed, 4 insertions, 10 deletions
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()