summaryrefslogtreecommitdiff
path: root/gen_vcs_info.sh
diff options
context:
space:
mode:
authorPhilipp Le <philipp-le-prviat@freenet.de>2020-07-01 23:40:02 +0200
committerPhilipp Le <philipp-le-prviat@freenet.de>2021-03-04 22:44:39 +0100
commitc2e3ef1e6336c9d8f078df0d73bf111913f9e750 (patch)
tree99c54b49ec2f64bf5cb0449f3f8421e8cbc6adb8 /gen_vcs_info.sh
parentc1db4510292b388c228d8d8dab18c6d09cc869ba (diff)
downloaddcs-lecture-notes-c2e3ef1e6336c9d8f078df0d73bf111913f9e750.zip
dcs-lecture-notes-c2e3ef1e6336c9d8f078df0d73bf111913f9e750.tar.gz
dcs-lecture-notes-c2e3ef1e6336c9d8f078df0d73bf111913f9e750.tar.bz2
Replace manually set revision number and date by Git commit number and date (automatically generated)
Diffstat (limited to 'gen_vcs_info.sh')
-rwxr-xr-xgen_vcs_info.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/gen_vcs_info.sh b/gen_vcs_info.sh
new file mode 100755
index 0000000..129ec2c
--- /dev/null
+++ b/gen_vcs_info.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+SHA1_SHORT=`git rev-parse --short HEAD`
+SHA1_LONG=`git rev-parse HEAD`
+COMMIT_NO=`git rev-list --count HEAD`
+TIME_ISO=`git log -1 --format=%cd --date=iso8601`
+TIME_ISO_STRICT=`git log -1 --format=%cd --date=iso8601-strict`
+DATE=`git log -1 --format=%cd --date=short`
+
+if [ -z "$(git status --porcelain)" ]; then
+ CLEAN="clean"
+ DIRTY=""
+ IS_CLEAN="\\def\\VcsIsClean{}"
+else
+ CLEAN=""
+ DIRTY="dirty"
+ IS_CLEAN=""
+fi
+
+echo -e "\\def\\VcsCommitHashShort{$SHA1_SHORT}
+\\def\\VcsCommitHashLong{$SHA1_LONG}
+\\def\\VcsCommitNo{$COMMIT_NO}
+\\def\\VcsCommitTime{$TIME_ISO}
+\\def\\VcsCommitTimeISO{$TIME_ISO_STRICT}
+\\def\\VcsCommitDate{$DATE}
+\\def\\VcsCleanStr{$CLEAN}
+\\def\\VcsDirtyStr{$DIRTY}
+$IS_CLEAN
+"