record the git repo

This commit is contained in:
2024-09-13 18:44:13 -05:00
committed by Celtic Minstrel
parent c371aac84b
commit 640492a428
3 changed files with 5 additions and 1 deletions

View File

@@ -91,12 +91,14 @@ def gen_gitrev(env, target, source):
status = "clean"
if subprocess.call(["git", "diff-index", "--quiet", "HEAD", "--"]) != 0:
status = "modified"
repo = subprocess.check_output(["git", "remote", "get-url", "origin"], text=True).strip()
with open(target[0].path, 'w') as gitrev_hpp:
print(file=gitrev_hpp)
print('#define GIT_REVISION "' + revid[0:7] + '"', file=gitrev_hpp)
print('#define GIT_TAG "' + fulltag + '"', file=gitrev_hpp)
print('#define GIT_TAG_REVISION "' + tagrev[0:7] + '"', file=gitrev_hpp)
print('#define GIT_STATUS "' + status + '"', file=gitrev_hpp)
print('#define GIT_REPO "' + repo + '"', file=gitrev_hpp)
print(file=gitrev_hpp)
if path.exists(".git"):
git_refs = ['.git/HEAD']

View File

@@ -7,5 +7,6 @@ REVID=`git rev-parse HEAD`;
export FULLTAG=`git tag --sort=v:refname | tail -n1`;
TAGREV=`git rev-parse $FULLTAG`;
STATUS=`git diff-index --quiet HEAD -- && echo "clean" || echo "modified"`;
REPO=`git remote get-url origin`;
echo -e "\n#define GIT_REVISION \"${REVID:0:7}\"\n#define GIT_TAG \"$FULLTAG\"\n#define GIT_TAG_REVISION \"${TAGREV:0:7}\"\n#define GIT_STATUS \"${STATUS}\"\n" > "$1/tools/gitrev.hpp"
echo -e "\n#define GIT_REVISION \"${REVID:0:7}\"\n#define GIT_TAG \"$FULLTAG\"\n#define GIT_TAG_REVISION \"${TAGREV:0:7}\"\n#define GIT_STATUS \"${STATUS}\"\n#define GIT_REPO \"${REPO}\"\n" > "$1/tools/gitrev.hpp"

View File

@@ -53,6 +53,7 @@ bool init_action_log(std::string command, std::string file) {
root_element.SetAttribute("SHA", GIT_REVISION);
root_element.SetAttribute("Tag", GIT_TAG);
root_element.SetAttribute("Status", GIT_STATUS);
root_element.SetAttribute("Repo", GIT_REPO);
log_document.InsertEndChild(root_element);
log_document.SaveFile(log_file);
recording = true;