summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2019-02-08 16:17:07 -0200
committerGeorge Marques <george@gmarqu.es>2019-02-08 16:17:07 -0200
commit874cbefa265af6665d3a6807f003aad3b9aabbc4 (patch)
tree29e282d8c643fa5903797830571d70dc1dc6ae5d
parent5e837b3f13ab1e3b31bb8d705e87820fa4eff21e (diff)
Get Git commit hash when Godot is a submodule
Submodules don't have a .git folder in the same place, but a .git file that points to the actual folder. This change take this into account.
-rw-r--r--methods.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/methods.py b/methods.py
index f8fc6c64ef..42eac7ca75 100644
--- a/methods.py
+++ b/methods.py
@@ -61,14 +61,22 @@ def update_version(module_version_string=""):
# NOTE: It is safe to generate this file here, since this is still executed serially
fhash = open("core/version_hash.gen.h", "w")
githash = ""
- if os.path.isfile(".git/HEAD"):
- head = open(".git/HEAD", "r").readline().strip()
+ gitfolder = ".git"
+
+ if os.path.isfile(".git"):
+ module_folder = open(".git", "r").readline().strip()
+ if module_folder.startswith("gitdir: "):
+ gitfolder = module_folder[8:]
+
+ if os.path.isfile(os.path.join(gitfolder, "HEAD")):
+ head = open(os.path.join(gitfolder, "HEAD"), "r").readline().strip()
if head.startswith("ref: "):
- head = ".git/" + head[5:]
+ head = os.path.join(gitfolder, head[5:])
if os.path.isfile(head):
githash = open(head, "r").readline().strip()
else:
githash = head
+
fhash.write("#define VERSION_HASH \"" + githash + "\"")
fhash.close()