2 # version.sh - execute in the root of the project to get the version number
4 # Unlimited permission to copy, distribute and modify this file is granted.
5 # This file is offered as-is, without any warranty.
7 test $# -gt 0 && PACKAGE_NAME
=$1
8 PACKAGE_NAME
=${PACKAGE_NAME=ngjackspa}
9 DEF_VER
="unknown_version"
14 # First try git-describe, then see if there is a VERSION file (included in
15 # release tarballs), then see if the project directory matches the project
16 # name, then use the default.
18 test -d .git ||
test -f .git
&&
19 VN
=$
(git describe
--abbrev=7 --match "version/*" --tags HEAD
--always 2>/dev
/null
) &&
24 git update-index
-q --refresh
25 test -z "$(git diff-index --name-only HEAD --)" ||
29 VN
=$
(echo "$VN" |
sed -e 's#^[vV][eE][rR][a-zA-Z]\{0,\}/##' -e 's/-/+/' -e 's/-/_/')
30 # <tag>+<num-of-commits>_g<hash>.dirty
32 test -f VERSION
&& test -s VERSION
34 VN
=$
(cat VERSION
) || VN
=$DEF_VER
36 VN
=$
(pwd |
sed -e 's#^.\{0,\}/##') &&
37 test x
"$VN" != x
"${VN#"$PACKAGE_NAME-"}"
39 VN
=${VN#"$PACKAGE_NAME-"}