File: git_version.sh

package info (click to toggle)
shadowsocks-libev 3.3.5%2Bds-16
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,496 kB
  • sloc: ansic: 14,124; sh: 1,338; makefile: 197; python: 111
file content (21 lines) | stat: -rwxr-xr-x 533 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash
set -e

# determine version and release number
GIT_DESCRIBE=$(git describe --tags --match 'v*' --long)
# GIT_DESCRIBE is like v3.0.3-11-g1e3f35c-dirty
if [[ ! "$GIT_DESCRIBE" =~ ^v([^-]+)-([0-9]+)-g([0-9a-f]+)$ ]]; then
    >&2 echo 'ERROR - unrecognized `git describe` output: '"$GIT_DESCRIBE"
    exit 1
fi

version=${BASH_REMATCH[1]}
commits=${BASH_REMATCH[2]}
short_hash=${BASH_REMATCH[3]}

release=1
if [ "${commits}" -gt 0 ] ; then
    release+=.${commits}.git${short_hash}
fi

echo "${version} ${release}"