forked from davidmoreno/onion
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-version-gen
More file actions
executable file
·40 lines (33 loc) · 819 Bytes
/
git-version-gen
File metadata and controls
executable file
·40 lines (33 loc) · 819 Bytes
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
39
40
#!/bin/sh
# usage: git-version-gen [srcdir]
DEF_VER="v0.8.0.GIT"
LF='
'
srcdir="."
if test "x${1}" != "x"
then
srcdir="${1}"
fi
# First see if there is a version file (included in release tarballs),
# then try git-describe, then default.
cd "${srcdir}" || exit 1
if test -f version
then
VN="`cat version`" || VN="${DEF_VER}"
elif test -d .git -o -f .git &&
VN="`git describe --match "v[0-9]*" --tags --abbrev=5 HEAD 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
# convert "v0.4.0-32-gf350f" to "v0.4.0.git32.f350f"
VN="`echo "${VN}" | sed -e 's/-\([0-9]*\)-g/.\1./g' -e 's/-/./g'`";
else
VN="${DEF_VER}"
fi
VN="`expr "${VN}" : v*'\(.*\)'`"
echo "${VN}" | tr -d "$LF"