calcurse-edge/build-aux/git-version-gen
Lukas Fleischer ddd0cb21fa Be a bit more fail-safe in "build-aux/git-version-gen".
The existence of a ".git" directory is not a sufficient condition to be
sure we are in a Git repository. Only overwrite the version information
file if `git describe` returns a non-empty string.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-22 02:47:38 +02:00

26 lines
420 B
Bash
Executable File

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