GNOME Bugzilla – Bug 611645
gnc-svnversion returns "too long" a string for git users
Last modified: 2018-06-29 22:35:59 UTC
The version string returned bu gnc-svnversion is used in the splash screen and the about acreen to indicate the vc version used for the build. For git users, the current behavior is to return the full hash of the commit, such as 1a2528c8ca1d43e8e9e21b0661f844d2b496f47d The below patch shortens this to the abbreviated hash, such as 1a2528c as well as adding a plus sign (+) to the end if there were uncommited changes in the repository at the time it was generated. The SVN-specific formatting (...SVN (r%s ...) still remains at this time. $ git diff origin/master diff --git a/util/gnc-svnversion b/util/gnc-svnversion index d70c22f..17085ac 100755 --- a/util/gnc-svnversion +++ b/util/gnc-svnversion @@ -45,9 +45,11 @@ fi # Maybe it's git? if test -d "${real_srcdir}"/.git then - githead=`git --git-dir "${real_srcdir}"/.git rev-parse HEAD 2>/dev/null` + githead=`git --git-dir "${real_srcdir}"/.git log -1 --pretty=%h HEAD 2>/dev/null` # short hash only if test $? = 0 ; then - echo $githead + echo -n $githead + git diff HEAD 2>&1 > /dev/null && echo -n "+" # Add a "+" to the hash if there are unstaged changes + echo exit 0 else exit 1
Created attachment 155081 [details] [review] Patch to change git "version strong" to something less unwieldy
Comment on attachment 155081 [details] [review] Patch to change git "version strong" to something less unwieldy Unicode
Comment on attachment 155081 [details] [review] Patch to change git "version strong" to something less unwieldy diff --git a/util/gnc-svnversion b/util/gnc-svnversion index d70c22f..17085ac 100755 --- a/util/gnc-svnversion +++ b/util/gnc-svnversion @@ -45,9 +45,11 @@ fi # Maybe it's git? if test -d "${real_srcdir}"/.git then - githead=`git --git-dir "${real_srcdir}"/.git rev-parse HEAD 2>/dev/null` + githead=`git --git-dir "${real_srcdir}"/.git log -1 --pretty=%h HEAD 2>/dev/null` # short hash only if test $? = 0 ; then - echo $githead + echo -n $githead + git diff HEAD 2>&1 > /dev/null && echo -n "+" # Add a "+" to the hash if there are unstaged changes + echo exit 0 else exit 1
Created attachment 155084 [details] [review] Same as before, but in "plain text" Saved as "text" under WindowsXP, instead of Unicode
Created attachment 155093 [details] [review] Use git ls-files and use --git-dir for out-of-tree use Properly detects changes and deletions in a non-language-specific way Will not detect changes in untracked files
Created attachment 155245 [details] [review] Checks for untracked files as well Made against r18811 -- after recent change to gnc-svnversion Adds checking for untracked files. Code for "ignoring" untracked files present as well, but line is commented out. Code that writes the version string is ./src/gnome-utils/gnc-splash.c: ver_string = g_strdup_printf(_("Version: GnuCash-%s svn (r%s built %s)"), and has not been changed.
Comment on attachment 155245 [details] [review] Checks for untracked files as well Committed in r18880
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=611645. Please update any external references or bookmarks.