mirror of
https://github.com/yrutschle/sslh.git
synced 2025-04-18 17:57:39 +03:00
Generate version tag based on file modification date if git is not present
This commit is contained in:
parent
9c3a838cc5
commit
56944e4d38
37
genver.sh
37
genver.sh
@ -7,27 +7,34 @@ else
|
|||||||
QUIET=0
|
QUIET=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! `(git status | grep -q "On branch") 2> /dev/null`; then
|
||||||
|
# If we don't have git, we can't work out what
|
||||||
|
# version this is. It must have been downloaded as a
|
||||||
|
# zip file. Github creates the zip file with all
|
||||||
|
# files dated from the last change: use the
|
||||||
|
# Makefile's modification time as a release number
|
||||||
|
release=zip-`stat -c "%y" Makefile | sed 's/ .*//'`
|
||||||
|
fi
|
||||||
|
|
||||||
if head=`git rev-parse --verify HEAD 2>/dev/null`; then
|
if head=`git rev-parse --verify HEAD 2>/dev/null`; then
|
||||||
|
|
||||||
if [ $QUIET -ne 1 ]; then
|
|
||||||
printf "#ifndef _VERSION_H_ \n"
|
|
||||||
printf "#define _VERSION_H_ \n\n"
|
|
||||||
printf "#define VERSION \""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# generate the version info based on the tag
|
# generate the version info based on the tag
|
||||||
(git describe --tags || git --describe || git describe --all --long) \
|
release=`(git describe --tags || git --describe || git describe --all --long) \
|
||||||
2>/dev/null | tr -d '\n'
|
2>/dev/null | tr -d '\n'`
|
||||||
|
|
||||||
# Are there uncommitted changes?
|
# Are there uncommitted changes?
|
||||||
git update-index --refresh --unmerged > /dev/null
|
git update-index --refresh --unmerged > /dev/null
|
||||||
if git diff-index --name-only HEAD | grep -v "^scripts/package" \
|
if git diff-index --name-only HEAD | grep -v "^scripts/package" \
|
||||||
| read dummy; then
|
| read dummy; then
|
||||||
printf '%s' -dirty
|
release="$release-dirty"
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $QUIET -ne 1 ]; then
|
|
||||||
printf "\"\n"
|
|
||||||
printf "\n#endif\n"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ $QUIET -ne 1 ]; then
|
||||||
|
printf "#ifndef _VERSION_H_ \n"
|
||||||
|
printf "#define _VERSION_H_ \n\n"
|
||||||
|
printf "#define VERSION \"$release\"\n"
|
||||||
|
printf "#endif\n"
|
||||||
|
else
|
||||||
|
printf "$release\n"
|
||||||
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user