calcurse-edge/build-aux/git-version-gen
Lukas Fleischer 8ab3106f6b git-version-gen: Add default version
Instead of bailing out early in the build process when neither a version
file nor a valid Git repository is detected, use a hardcoded default
version string. This fixes building from shallow clones or Git
snapshots.

Also fixes GitHub issue #22.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 22:35:36 +02:00

23 lines
444 B
Bash
Executable File

#!/bin/sh
if [ "$#" -ne 1 ]
then
echo "usage: git-version-gen <verfile>" >&2
exit 1
fi
DEF_VER=4.2.2.dev
VERFILE="$1"
if [ -d '.git' ]
then
git update-index --refresh > /dev/null 2>&1
VERSION=`git describe --abbrev=4 --match='v[0-9]*' --dirty 2>/dev/null`
VERSION=`echo "$VERSION" | sed 's/^v//'`
[ -n "$VERSION" ] && printf "%s" "$VERSION" >"$VERFILE"
fi
[ -f "$VERFILE" ] || printf "%s" "$DEF_VER" >"$VERFILE"
cat "$VERFILE"