Debian Codegraph @

build-aux/git-version-gen

raw
1 #!/bin/sh
2
3 tarball_version_file=VERSION
4
5 # Use tarball version file (included in release tarballs) if present,
6 # otherwise, try git-describe
7 if test -f $tarball_version_file
8 then
9 v=$(cat $tarball_version_file) || v=
10 fi
11
12 if test "x$v" != "x"
13 then
14 : # use $v
15 # Make sure it's a Git tree
16 elif test "$(git log -1 --pretty=format:x 2>&1)" = "x"
17 then
18 v=$(git describe --match 'v[0-9]*' HEAD 2>/dev/null | sed -e 's/^v//') \
19 || v="UNKNOWN"
20
21 # Append "-dirty" suffix if there is local change
22 git update-index --refresh > /dev/null 2>&1
23 if test "x$(git diff-index --name-only HEAD 2>/dev/null)" != "x"
24 then
25 v="$v-dirty"
26 fi
27 fi
28
29 printf "%s" "$v"