Update configuration method
authorColin Clark <colin.clark@cclark.uk>
Tue, 25 Jan 2022 10:16:31 +0000 (10:16 +0000)
committerColin Clark <colin.clark@cclark.uk>
Tue, 25 Jan 2022 10:16:31 +0000 (10:16 +0000)
Update configuration method so that releases can be auto-generated.

configure.ac
gen_changelog.sh
version.sh [new file with mode: 0755]

index 9bb3b36..103c3fa 100644 (file)
@@ -15,7 +15,7 @@ dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 dnl GNU General Public License for more details.
 
 AC_PREREQ(2.57)
-AC_INIT([geeqie], m4_translit(m4_esyscmd([if [ $(git tag --list 'v[1-9]*' --points-at HEAD | wc -c) -gt 0 ]; then git tag --list v[1-9]* --points-at HEAD | tail -n 1 | tr -d 'v' ; else git tag --list v[1-9]* | tail -n 1 | tr -d 'v' && echo "+git" && git log --max-count=1 --date=format:"%Y%m%d" --format="%ad" && echo "-" && git rev-parse --quiet --verify --short HEAD; fi ]), m4_newline), [geeqie@freelists.org], [], [http://www.geeqie.org/])
+AC_INIT([geeqie], m4_translit(m4_esyscmd([./version.sh]), m4_newline), [geeqie@freelists.org], [], [http://www.geeqie.org/])
 
 # Add -Werror to the default CFLAGS
 CFLAGS+=" -Werror -Wno-error=deprecated-declarations -Wno-error=sign-compare -Wno-error=return-type"
index 33aceba..2d42d13 100755 (executable)
@@ -11,6 +11,7 @@
 
 [ ! -e "ChangeLog.gqview" ] && exit 1
 [ ! -x "$(command -v git)" ] && exit 0
+[ ! -d ".git" ] && exit 0
 
 LC_ALL=C git log --no-merges --no-notes --encoding=UTF-8 --no-follow --use-mailmap 1b58572cf58e9d2d4a0305108395dab5c66d3a09..HEAD > ChangeLog.$$.new && \
 cat ChangeLog.gqview >> ChangeLog.$$.new && \
diff --git a/version.sh b/version.sh
new file mode 100755 (executable)
index 0000000..fb52741
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+## @file
+## @brief Generate the Geeqie version number
+##
+## This script is called from configure.ac
+##
+## If the current branch is "master" a revison number is generated of the form:  
+## <n.m>+git<date of last commit>-<last commit hash>  
+## where <n.m> is the most recent tag.  
+## e.g. 1.7+git20220117-732b6935  
+##
+## If not on "master" or no .git directory, a revision number extracted
+## from the first line of the NEWS file is generated.  
+## This situation will occur when compiling from a source .tar.
+## or for a release.  
+## The first line of NEWS must be of the form:  
+## Geeqie <n.m[.p]>
+##
+
+if [ -d .git ]
+then
+       branch=$(git rev-parse --abbrev-ref HEAD)
+
+       if [ "$branch" == "master" ]
+       then
+               IFS=$'.'
+# shellcheck disable=SC2046
+               set -- $(git tag --list v[1-9]* | tail -n 1 | tr -d 'v')
+
+               major_version=$1
+               minor_version=$2
+#              patch_version=$3  # not used on master branch
+
+               echo "$major_version" && echo "." && echo "$minor_version" && echo "+git" && git log --max-count=1 --date=format:"%Y%m%d" --format="%ad" && echo "-" && git rev-parse --quiet --verify --short HEAD
+       else
+               version=$(head -1 NEWS)
+# shellcheck disable=SC2086
+               set -- $version
+               echo "$2"
+       fi
+else
+       version=$(head -1 NEWS)
+# shellcheck disable=SC2086
+       set -- $version
+       echo "$2"
+fi
+