diff --git a/lib/core/revision.py b/lib/core/revision.py index a3ecf73d3..6e0960c9c 100644 --- a/lib/core/revision.py +++ b/lib/core/revision.py @@ -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) diff --git a/lib/core/update.py b/lib/core/update.py index 9d342a52c..e929add3e 100644 --- a/lib/core/update.py +++ b/lib/core/update.py @@ -17,6 +17,7 @@ from lib.core.common import getUnicode from lib.core.data import conf from lib.core.data import logger from lib.core.data import paths +from lib.core.revision import getRevisionNumber from lib.core.settings import GIT_REPOSITORY from lib.core.settings import IS_WIN from lib.core.settings import REVISION @@ -49,7 +50,9 @@ def update(): success = not process.returncode if success: - logger.info("%s the latest revision '%s'" % ("already at" if "Already" in stdout else "updated to", REVISION)) + import lib.core.settings + _ = lib.core.settings.REVISION = getRevisionNumber() + logger.info("%s the latest revision '%s'" % ("already at" if "Already" in stdout else "updated to", _)) else: logger.error("update could not be completed ('%s')" % re.sub(r"\W+", " ", stderr).strip())