File: GEN-VERSION-FILE

package info (click to toggle)
todotxt-cli 2.11.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, buster, sid
  • size: 1,312 kB
  • sloc: sh: 5,393; makefile: 67
file content (38 lines) | stat: -rwxr-xr-x 571 bytes parent folder | download
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
#!/bin/sh
# Based on git's GIT-VERSION-GEN.

VF=VERSION-FILE
DEF_VER=v2.11

LF='
'

if test -d .git -o -f .git &&
	VN=$(git describe --abbrev=0 --tags 2>/dev/null) &&
	case "$VN" in
	*$LF*) (exit 1) ;;
	v[0-9]*)
		git update-index -q --refresh
		test -z "$(git diff-index --name-only HEAD --)" ||
		VN="$VN-dirty" ;;
	esac
then
	VN=$(echo "$VN" | sed -e 's/-/./g');
else
	VN="$DEF_VER"
fi

VN=$(expr "$VN" : v*'\(.*\)')

if test -r $VF
then
	VC=$(sed -e 's/^VERSION=//' <$VF)
else
	VC=unset
fi
test "$VN" = "$VC" || {
	echo >&2 "VERSION=$VN"
	echo "VERSION=$VN" >$VF
}