From: daid Date: Mon, 18 Nov 2013 14:10:54 +0000 (+0100) Subject: Add patch for git submodule version. Fixing issue #612 X-Git-Tag: 13.11.2~7 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=3fc7846bf43c584df487aaeca88e3e32f0a1ad30;p=cura.git Add patch for git submodule version. Fixing issue #612 --- diff --git a/Cura/util/version.py b/Cura/util/version.py index 5121216d..051f2414 100644 --- a/Cura/util/version.py +++ b/Cura/util/version.py @@ -5,6 +5,7 @@ import os import sys import urllib2 import platform +import subprocess try: from xml.etree import cElementTree as ElementTree except: @@ -13,15 +14,24 @@ except: from Cura.util import resources def getVersion(getGitVersion = True): - gitPath = os.path.abspath(os.path.join(os.path.split(os.path.abspath(__file__))[0], "../../.git")) + gitPath = os.path.abspath(os.path.join(os.path.split(os.path.abspath(__file__))[0], "../..")) if hasattr(sys, 'frozen'): versionFile = os.path.normpath(os.path.join(resources.resourceBasePath, "version")) else: versionFile = os.path.abspath(os.path.join(os.path.split(os.path.abspath(__file__))[0], "../version")) - if os.path.exists(gitPath): + + if getGitVersion: + gitProcess = subprocess.Popen(args = "git show -s --pretty=format:%H", shell = True, cwd = gitPath, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + (stdoutdata, stderrdata) = gitProcess.communicate() + + if gitProcess.returncode == 0: + return stdoutdata + + gitHeadFile = gitPath + "/.git/refs/heads/SteamEngine" + if os.path.isfile(gitHeadFile): if not getGitVersion: return "dev" - f = open(gitPath + "/refs/heads/SteamEngine", "r") + f = open(gitHeadFile, "r") version = f.readline() f.close() return version.strip()