summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/fonts/fonts-tlwg/build-aux/git-version-gen
blob: 3d78ba2dd7ba8bb9d1b560f6ce35a5608da1dac7 (plain)
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"