]> git.lyx.org Git - lyx.git/commitdiff
Add the git commit (if applicable) to LyX version
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 10 Oct 2014 10:12:17 +0000 (12:12 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 10 Oct 2014 10:12:17 +0000 (12:12 +0200)
This only works for autotools right now, but adding that to cmake is trivial

config/lyxinclude.m4
configure.ac
src/LyX.cpp
src/frontends/qt4/GuiAbout.cpp
src/version.cpp
src/version.h

index ac0b6427f82760d2035265231b3e146cb65226ae..c781c1e57403a0cc1010669ecc074150bc4f2b3a 100644 (file)
@@ -8,9 +8,10 @@ dnl Usage LYX_CHECK_VERSION   Displays version of LyX being built and
 dnl sets variable "build_type"
 AC_DEFUN([LYX_CHECK_VERSION],[
 echo "configuring LyX version" AC_PACKAGE_VERSION
+
+AC_MSG_CHECKING([for build type])
 lyx_devel_version=no
 lyx_prerelease=no
-AC_MSG_CHECKING([for build type])
 AC_ARG_ENABLE(build-type,
   AC_HELP_STRING([--enable-build-type=TYPE],[set build setting according to TYPE=rel(ease), pre(release), dev(elopment), prof(iling), gprof]),
   [case $enableval in
@@ -38,6 +39,16 @@ esac
 AC_SUBST(lyx_devel_version)
 ])
 
+dnl If LyX is compiled from a git clone, find the HEAD commit hash
+dnl
+dnl
+AC_DEFUN([LYX_CHECK_GIT_COMMIT], [
+AC_MSG_CHECKING([for git commit hash])
+lyxgitcommit=`cd "$srcdir" && git log -1 --pretty=format:%H 2>/dev/null || true`
+test x$lyxgitcommit = x && lyxgitcommit="none"
+AC_MSG_RESULT($lyxgitcommit)
+])
+
 
 dnl Define the option to set a LyX version on installed executables and directories
 dnl
index 7ba65bb193683cf84c7cd690f3efb374d20eb8fb..8539c7cfdb347a206a95f1f04ba2134e4f519956 100644 (file)
@@ -35,6 +35,8 @@ AM_INIT_AUTOMAKE([foreign dist-bzip2 no-define 1.8] LYX_OBJECTS_LAYOUT)
 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
 PACKAGE=$save_PACKAGE
 
+LYX_CHECK_GIT_COMMIT
+
 # Allow to build some parts of the code as one big chunk
 m4_define([ALLPARTS],[boost,client,insets,mathed,core,tex2lyx,frontend_qt])
 AC_ARG_ENABLE(monolithic-build,
@@ -322,6 +324,7 @@ AC_DEFINE_UNQUOTED([PROGRAM_SUFFIX],
        "${version_suffix}",[Program version suffix])
 
 AC_DEFINE_UNQUOTED([LYX_DATE],"$LYX_DATE",[Date of release])
+AC_DEFINE_UNQUOTED([LYX_GIT_COMMIT_HASH], "$lyxgitcommit", [Git commit])
 AC_DEFINE_UNQUOTED([VERSION_INFO],"$VERSION_INFO",[Full version info])
 AC_DEFINE_UNQUOTED([LYX_DIR_VER],"$lyx_dir_ver",[Versioned env var for system dir])
 AC_DEFINE_UNQUOTED([LYX_USERDIR_VER],"$lyx_userdir_ver",[Versioned env var for user dir])
index 050db524543102439d692d888562731b4da17c6e..023f80dfc121c446ac93b01f1d7cbd853de41939 100644 (file)
@@ -1089,9 +1089,11 @@ int parse_version(string const &, string const &, string &)
 {
        cout << "LyX " << lyx_version
               << " (" << lyx_release_date << ")" << endl;
+       if (string(lyx_git_commit_hash) != "none")
+               cout << to_utf8(_("  Git commit hash "))
+                    << string(lyx_git_commit_hash).substr(0,8) << endl;
        cout << to_utf8(bformat(_("Built on %1$s[[date]], %2$s[[time]]"),
                from_ascii(__DATE__), from_ascii(__TIME__))) << endl;
-
        cout << lyx_version_info << endl;
        exit(0);
        return 0;
index 09834d41f5f9c5b7aaae531bf8afc16536b76a0e..c75fec018005eb516e68949a24a8dda43b6c75d2 100644 (file)
@@ -115,7 +115,12 @@ static QString version()
        docstring version_date =
                bformat(_("LyX Version %1$s\n(%2$s)"),
                        from_ascii(lyx_version),
-                       qstring_to_ucs4(loc_release_date))+"\n\n";
+                       qstring_to_ucs4(loc_release_date))+"\n";
+       if (std::string(lyx_git_commit_hash) != "none")
+               version_date += _("Built from git commit hash ")
+                       + from_utf8(lyx_git_commit_hash).substr(0,8);
+       version_date += "\n";
+
        QString res;
        QTextStream out(&res);
        out << toqstr(version_date);
@@ -138,6 +143,9 @@ static QString buildinfo()
        QTextStream out(&res);
        out << "LyX " << lyx_version
                << " (" << lyx_release_date << ")" << endl;
+       if (std::string(lyx_git_commit_hash) != "none")
+               out << qt_("  Git commit hash ")
+                   << QString(lyx_git_commit_hash).left(8) << endl;
        out << toqstr(bformat(_("Built on %1$s[[date]], %2$s[[time]]"),
                from_ascii(__DATE__), from_ascii(__TIME__))) << endl;
 
index 1e4aa324396b0a90fb026f3d3a92d495979f5d07..4d46e145e456ea17708020e28d18aab2ca585536 100644 (file)
@@ -20,6 +20,8 @@ extern char const * const lyx_version = PACKAGE_VERSION;
 extern const int lyx_version_major = LYX_MAJOR_VERSION;
 extern const int lyx_version_minor = LYX_MINOR_VERSION;
 ///
+extern char const * const lyx_git_commit_hash = LYX_GIT_COMMIT_HASH;
+///
 extern char const * const lyx_release_date = LYX_DATE;
 
 /// Package identifier (lyx[-<version-suffix>])
index 9293e4f6b08ec9b86056e569e6d9b76378cbd794..d952ab52046280ce51317f63f1a1364f93962e5d 100644 (file)
@@ -20,6 +20,8 @@ extern char const * const lyx_version;
 extern const int lyx_version_major;
 extern const int lyx_version_minor;
 ///
+extern char const * const lyx_git_commit_hash;
+///
 extern char const * const lyx_release_date;
 
 /// Package identifier (lyx[-<version-suffix>])