From 508a67a69eafd07a2e1ce9020983e7113b91d919 Mon Sep 17 00:00:00 2001 From: Torgny Nyblom Date: Tue, 21 Dec 2010 10:30:15 +0100 Subject: Fix the --version option When supplying --version the git commit that was used to create the version should be printed to stdout. --- src/main.cpp | 4 ++++ src/src.pro | 8 ++++++++ 2 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 1cabbad..e6a2bfa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -117,6 +117,10 @@ int main(int argc, char **argv) CommandLineParser::addOptionDefinitions(options); Stats::init(); CommandLineParser *args = CommandLineParser::instance(); + if(args->contains(QLatin1String("version"))) { + printf("Git version: %s\n", VER); + return 0; + } if (args->contains(QLatin1String("help")) || args->arguments().count() != 1) { args->usage(QString(), "[Path to subversion repo]"); return 0; diff --git a/src/src.pro b/src/src.pro index 2626a6f..da6d40d 100644 --- a/src/src.pro +++ b/src/src.pro @@ -6,6 +6,14 @@ SVN_INCLUDE = /usr/include/subversion-1 /usr/local/include/subversion-1 APR_INCLUDE = /usr/include/apr-1.0 /usr/include/apr-1 /usr/local/include/apr-1 exists(local-config.pri):include(local-config.pri) +VERSION = $$system(git --no-pager show --pretty=oneline --no-notes | head -1 | cut -b-40) + !isEmpty(VERSION){ + VERSION = $${VERSION} + } + +VERSTR = '\\"$${VERSION}\\"' # place quotes around the version string +DEFINES += VER=\"$${VERSTR}\" # create a VER macro containing the version string + TEMPLATE = app TARGET = ../svn-all-fast-export DEPENDPATH += . -- cgit v1.2.1