File: version.sh

package info (click to toggle)
geeqie 1%3A2.5-8
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 16,780 kB
  • sloc: cpp: 110,189; xml: 11,497; sh: 3,681; awk: 124; perl: 88; python: 80; makefile: 23
file content (48 lines) | stat: -rwxr-xr-x 1,324 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh

## @file
## @brief Generate the Geeqie version number
##
## This script is called from meson.build
##
## 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 ] && [ -x "$(command -v 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

		printf '%s%s%s%s%s%s%s' "$major_version" "." "$minor_version" "+git" "$(git log --max-count=1 --date=format:"%Y%m%d" --format="%ad")" "-" "$(git rev-parse --quiet --verify --short HEAD)"
	else
		version=$(head -1 NEWS)
		# shellcheck disable=SC2086
		set -- $version
		printf '%s' "$2"
	fi
else
	version=$(head -1 NEWS)
	# shellcheck disable=SC2086
	set -- $version
	printf '%s' "$2"
fi