summaryrefslogtreecommitdiffstats
path: root/src/b2qt-update-util
diff options
context:
space:
mode:
Diffstat (limited to 'src/b2qt-update-util')
-rw-r--r--src/b2qt-update-util/b2qt-update-util.pro19
-rw-r--r--src/b2qt-update-util/main.cpp3
2 files changed, 22 insertions, 0 deletions
diff --git a/src/b2qt-update-util/b2qt-update-util.pro b/src/b2qt-update-util/b2qt-update-util.pro
index 5ad8f71..0b5ab32 100644
--- a/src/b2qt-update-util/b2qt-update-util.pro
+++ b/src/b2qt-update-util/b2qt-update-util.pro
@@ -2,3 +2,22 @@ QT = core
SOURCES = main.cpp
INSTALLS += target
target.path = /usr/bin
+
+# Find out git hash
+unix:system(which git):HAS_GIT=TRUE
+win32:system(where git.exe):HAS_GIT=TRUE
+contains(HAS_GIT, TRUE) {
+ GIT_HASH=$$system(git log -1 --format=%H)
+ !system(git diff-index --quiet HEAD): GIT_HASH="$$GIT_HASH-dirty"
+ GIT_VERSION=$$system(git describe --tags --exact-match)
+ isEmpty(GIT_VERSION) : GIT_VERSION="unknown"
+} else {
+ GIT_HASH="unknown"
+ GIT_VERSION="unknown"
+}
+
+isEmpty(GIT_VERSION) : error("No suitable tag found")
+isEmpty(GIT_HASH) : error("No hash available")
+
+DEFINES+="GIT_HASH=\\\"$$GIT_HASH\\\""
+DEFINES+="GIT_VERSION=\\\"$$GIT_VERSION\\\""
diff --git a/src/b2qt-update-util/main.cpp b/src/b2qt-update-util/main.cpp
index d22019e..137cbd5 100644
--- a/src/b2qt-update-util/main.cpp
+++ b/src/b2qt-update-util/main.cpp
@@ -134,6 +134,9 @@ int main(int argc, char **argv)
return start_update(QString());
else
return start_update(args.takeFirst());
+ } else if (arg == "version") {
+ printf("Version %s, SHA1 %s\n", GIT_VERSION, GIT_HASH);
+ return 0;
} else {
usage();
return 1;