Fix for an Issue #121

This commit is contained in:
Miroslav Stampar
2012-07-26 00:02:38 +02:00
parent 4a0b55f651
commit 18b1d1efd6
2 changed files with 16 additions and 6 deletions

View File

@@ -21,7 +21,7 @@ def getRevisionNumber():
_ = os.path.dirname(__file__)
while True:
filePath = os.path.join(_, ".git/refs/heads/master").replace('/', os.path.sep)
filePath = os.path.join(_, ".git", "HEAD")
if os.path.exists(filePath):
break
else:
@@ -30,10 +30,17 @@ def getRevisionNumber():
break
else:
_ = os.path.dirname(_)
if filePath:
with open(filePath, "r") as f:
match = re.match(r"(?i)[0-9a-f]{32}", f.read())
retVal = match.group(0) if match else None
while True:
if filePath and os.path.isfile(filePath):
with open(filePath, "r") as f:
content = f.read()
filePath = None
if content.startswith("ref: "):
filePath = os.path.join(_, ".git", content.replace("ref: ", "")).strip()
else:
match = re.match(r"(?i)[0-9a-f]{32}", content)
retVal = match.group(0) if match else None
break
if not retVal:
process = execute("git rev-parse --verify HEAD", shell=True, stdout=PIPE, stderr=PIPE)