From fca13283e1c4ab440d0be261029e84632f3993f7 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Wed, 22 Feb 2017 09:42:07 +0100 Subject: [PATCH] changed generation of git-revision.h which allows to keep it up-to-date. Aditionally git-branch info has been added. --- src/Makefile.am | 2 +- src/any2many.cpp | 4 ++-- src/dump_header.cpp | 4 ++-- src/git_revision.sh | 28 ++++++++++++++++++++++++ src/msr2data.cpp | 4 ++-- src/musrFT.cpp | 4 ++-- src/musrRootValidation.cpp | 4 ++-- src/musredit/main.cpp | 2 +- src/musredit_qt5/PMusrEditAbout.cpp | 3 ++- src/musredit_qt5/PTextEdit.cpp | 1 - src/musredit_qt5/forms/PMusrEditAbout.ui | 27 ++++++++++++++++++----- src/musredit_qt5/main.cpp | 2 +- src/musrfit.cpp | 4 ++-- src/musrt0.cpp | 4 ++-- src/musrview.cpp | 4 ++-- src/write_musrRoot_runHeader.cpp | 4 ++-- 16 files changed, 73 insertions(+), 28 deletions(-) create mode 100755 src/git_revision.sh diff --git a/src/Makefile.am b/src/Makefile.am index 3d24b418..d7d1e071 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,7 +2,7 @@ BUILT_SOURCES = git-revision.h git-revision.h : Makefile - echo \#define GIT_REVISION \"`git log -n 1 --pretty=format:"%ad - %h"`\" > include/git-revision.h + sh git_revision.sh ./include git-revision.h if PNEXUS_ENABLED PNEXUSDIRS = external/nexus diff --git a/src/any2many.cpp b/src/any2many.cpp index 0fb896fa..9de7779d 100644 --- a/src/any2many.cpp +++ b/src/any2many.cpp @@ -198,9 +198,9 @@ int main(int argc, char *argv[]) any2many_syntax(); else if (strstr(argv[1], "--v")) { #ifdef HAVE_CONFIG_H - cout << endl << "any2many version: " << PACKAGE_VERSION << ", git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "any2many version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #else - cout << endl << "any2many git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "any2many git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #endif } else { any2many_syntax(); diff --git a/src/dump_header.cpp b/src/dump_header.cpp index 74d6a64b..b68d2e9d 100644 --- a/src/dump_header.cpp +++ b/src/dump_header.cpp @@ -762,9 +762,9 @@ int main(int argc, char *argv[]) return 0; } else if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-v")) { #ifdef HAVE_CONFIG_H - cout << endl << "dump_header: version " << PACKAGE_VERSION << ", git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "dump_header version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #else - cout << endl << "dump_header: git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "dump_header git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #endif return 0; } else if (!strcmp(argv[i], "-rn") || !strcmp(argv[i], "--runNo")) { diff --git a/src/git_revision.sh b/src/git_revision.sh new file mode 100755 index 00000000..5c706d27 --- /dev/null +++ b/src/git_revision.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +echo "Generating header for git hash" $1 $2 +GIT_HEADER="$1/$2" +if [ -z "$2" ]; then + GIT_HEADER="$1/git-revision.h" +fi + +GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` + +GIT_VERSION=`git log -n 1 --pretty=format:"%ad - %h"` +if grep --quiet "$GIT_VERSION" $GIT_HEADER; then + echo "No need to generate new $GIT_HEADER - git hash is unchanged" + exit 0; +fi + +echo "git branch is : " $GIT_BRANCH +echo "git version is : " $GIT_VERSION + +echo "#ifndef GIT_VERSION_H" > $GIT_HEADER +echo "#define GIT_VERSION_H" >> $GIT_HEADER +echo "" >> $GIT_HEADER +echo "#define GIT_BRANCH \"$GIT_BRANCH\"" >> $GIT_HEADER +echo "#define GIT_CURRENT_SHA1 \"$GIT_VERSION\"" >> $GIT_HEADER +echo "" >> $GIT_HEADER +echo "#endif //GIT_VERSION_H" >> $GIT_HEADER + +echo "file is generated into" $GIT_HEADER diff --git a/src/msr2data.cpp b/src/msr2data.cpp index 79a95b09..2560d30e 100644 --- a/src/msr2data.cpp +++ b/src/msr2data.cpp @@ -516,9 +516,9 @@ int main(int argc, char *argv[]) return 0; } else if (!strcmp(argv[1], "--version")) { #ifdef HAVE_CONFIG_H - cout << endl << "msr2data version: " << PACKAGE_VERSION << ", git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "msr2data version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #else - cout << endl << "msr2data git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "msr2data git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #endif return 0; } else { diff --git a/src/musrFT.cpp b/src/musrFT.cpp index 85ca609f..d3dd0905 100644 --- a/src/musrFT.cpp +++ b/src/musrFT.cpp @@ -298,9 +298,9 @@ Int_t musrFT_parse_options(Int_t argc, Char_t *argv[], musrFT_startup_param &sta tstr = argv[i]; if (tstr.BeginsWith("--version")) { #ifdef HAVE_CONFIG_H - cout << endl << "musrFT version: " << PACKAGE_VERSION << ", git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "musrFT version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #else - cout << endl << "musrFT git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "musrFT git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #endif return 1; } else if (tstr.BeginsWith("--help")) { diff --git a/src/musrRootValidation.cpp b/src/musrRootValidation.cpp index eb551442..e6555e5c 100644 --- a/src/musrRootValidation.cpp +++ b/src/musrRootValidation.cpp @@ -575,9 +575,9 @@ int main(int argc, char *argv[]) } else if (argc==2) { if (!strcmp(argv[1], "--version")) { #ifdef HAVE_CONFIG_H - cout << endl << "musrRootValidation version: " << PACKAGE_VERSION << ", git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "musrRootValidation version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #else - cout << endl << "musrRootValidation git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "musrRootValidation git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #endif return 0; } else { diff --git a/src/musredit/main.cpp b/src/musredit/main.cpp index 8948dca1..950b6682 100644 --- a/src/musredit/main.cpp +++ b/src/musredit/main.cpp @@ -53,7 +53,7 @@ int main( int argc, char ** argv ) cout << endl << endl; return 0; } else if (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")) { - cout << endl << "musredit git-rev: " << GIT_REVISION; + cout << endl << "musredit git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1; cout << endl << endl; return 0; } diff --git a/src/musredit_qt5/PMusrEditAbout.cpp b/src/musredit_qt5/PMusrEditAbout.cpp index 614b9610..f918ed9e 100644 --- a/src/musredit_qt5/PMusrEditAbout.cpp +++ b/src/musredit_qt5/PMusrEditAbout.cpp @@ -38,7 +38,8 @@ PMusrEditAbout::PMusrEditAbout(QWidget *parent, Qt::WindowFlags f) : QDialog(par { setupUi(this); - fGitRev_label->setText(QString("git: %1").arg(GIT_REVISION)); + fGitBranch_label->setText(QString("git-branch: %1").arg(GIT_BRANCH)); + fGitRev_label->setText(QString("git-rev: %1").arg(GIT_CURRENT_SHA1)); setModal(true); } diff --git a/src/musredit_qt5/PTextEdit.cpp b/src/musredit_qt5/PTextEdit.cpp index 2dff05f1..ff256bed 100644 --- a/src/musredit_qt5/PTextEdit.cpp +++ b/src/musredit_qt5/PTextEdit.cpp @@ -72,7 +72,6 @@ using namespace std; #include "PDumpOutputHandler.h" #include "PPrefsDialog.h" #include "PGetMusrFTOptionsDialog.h" -//#include "PGetDefaultDialog.h" #include "PMusrEditAbout.h" #include "PMsr2DataDialog.h" diff --git a/src/musredit_qt5/forms/PMusrEditAbout.ui b/src/musredit_qt5/forms/PMusrEditAbout.ui index 4917bf82..0b5849cb 100644 --- a/src/musredit_qt5/forms/PMusrEditAbout.ui +++ b/src/musredit_qt5/forms/PMusrEditAbout.ui @@ -7,7 +7,7 @@ 0 0 395 - 187 + 202 @@ -20,10 +20,10 @@ - 12 - 12 + 13 + 13 371 - 161 + 181 @@ -46,6 +46,23 @@ p, li { white-space: pre-wrap; } + + + + + 75 + true + true + + + + <html><head/><body><p><span style=" font-weight:600; font-style:italic;">git-branch: </span></p></body></html> + + + Qt::AlignCenter + + + @@ -56,7 +73,7 @@ p, li { white-space: pre-wrap; } - git: + git-rev: Qt::AlignCenter diff --git a/src/musredit_qt5/main.cpp b/src/musredit_qt5/main.cpp index 8948dca1..950b6682 100644 --- a/src/musredit_qt5/main.cpp +++ b/src/musredit_qt5/main.cpp @@ -53,7 +53,7 @@ int main( int argc, char ** argv ) cout << endl << endl; return 0; } else if (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")) { - cout << endl << "musredit git-rev: " << GIT_REVISION; + cout << endl << "musredit git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1; cout << endl << endl; return 0; } diff --git a/src/musrfit.cpp b/src/musrfit.cpp index 10264fe1..0aee41cd 100644 --- a/src/musrfit.cpp +++ b/src/musrfit.cpp @@ -457,9 +457,9 @@ int main(int argc, char *argv[]) if (argc == 2) { if (!strcmp(argv[1], "--version")) { #ifdef HAVE_CONFIG_H - cout << endl << "musrfit version: " << PACKAGE_VERSION << ", git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "musrfit version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #else - cout << endl << "musrfit git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "musrfit git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #endif return PMUSR_SUCCESS; } diff --git a/src/musrt0.cpp b/src/musrt0.cpp index 197e60b7..e354ba97 100644 --- a/src/musrt0.cpp +++ b/src/musrt0.cpp @@ -232,9 +232,9 @@ Int_t main(Int_t argc, Char_t *argv[]) for (int i=1; i> musrt0 version: " << PACKAGE_VERSION << ", git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "musrt0 version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #else - cout << endl << ">> musrt0 git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "musrt0 git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #endif return PMUSR_SUCCESS; } else if (!strcmp(argv[i], "--help")) { diff --git a/src/musrview.cpp b/src/musrview.cpp index cc0d947b..0c0da86b 100644 --- a/src/musrview.cpp +++ b/src/musrview.cpp @@ -127,9 +127,9 @@ int main(int argc, char *argv[]) } } else if (!strcmp(argv[i], "--version")) { #ifdef HAVE_CONFIG_H - cout << endl << "musrview version: " << PACKAGE_VERSION << ", git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "musrview version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #else - cout << endl << "musrview git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "musrview git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #endif return PMUSR_SUCCESS; } else if (!strcmp(argv[i], "--help")) { diff --git a/src/write_musrRoot_runHeader.cpp b/src/write_musrRoot_runHeader.cpp index b5c5380d..363cddf0 100644 --- a/src/write_musrRoot_runHeader.cpp +++ b/src/write_musrRoot_runHeader.cpp @@ -62,9 +62,9 @@ int main(int argc, char *argv[]) if (!strcmp(argv[1], "--version")) { #ifdef HAVE_CONFIG_H - cout << endl << "write_musrRoot_runHeader version: " << PACKAGE_VERSION << ", git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "write_musrRoot_runHeader version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #else - cout << endl << "write_musrRoot_runHeader git-rev: " << GIT_REVISION << endl << endl; + cout << endl << "write_musrRoot_runHeader git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << endl << endl; #endif return 0; }