File: git-version-gen

package info (click to toggle)
libthai 0.1.28-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 3,112 kB
  • sloc: ansic: 4,417; sh: 4,277; makefile: 288
file content (29 lines) | stat: -rwxr-xr-x 683 bytes parent folder | download | duplicates (13)
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
#!/bin/sh

tarball_version_file=VERSION

# Use tarball version file (included in release tarballs) if present,
# otherwise, try git-describe
if test -f $tarball_version_file
then
    v=$(cat $tarball_version_file) || v=
fi

if test "x$v" != "x"
then
    : # use $v
# Make sure it's a Git tree
elif test "$(git log -1 --pretty=format:x 2>&1)" = "x"
then
    v=$(git describe --match 'v[0-9]*' HEAD 2>/dev/null | sed -e 's/^v//') \
        || v="UNKNOWN"

    # Append "-dirty" suffix if there is local change
    git update-index --refresh > /dev/null 2>&1
    if test "x$(git diff-index --name-only HEAD 2>/dev/null)" != "x"
    then
        v="$v-dirty"
    fi
fi

printf "%s" "$v"