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>
This commit is contained in:
parent
2fe9c7efce
commit
8ab3106f6b
@ -6,6 +6,7 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
DEF_VER=4.2.2.dev
|
||||||
VERFILE="$1"
|
VERFILE="$1"
|
||||||
|
|
||||||
if [ -d '.git' ]
|
if [ -d '.git' ]
|
||||||
@ -13,14 +14,9 @@ then
|
|||||||
git update-index --refresh > /dev/null 2>&1
|
git update-index --refresh > /dev/null 2>&1
|
||||||
VERSION=`git describe --abbrev=4 --match='v[0-9]*' --dirty 2>/dev/null`
|
VERSION=`git describe --abbrev=4 --match='v[0-9]*' --dirty 2>/dev/null`
|
||||||
VERSION=`echo "$VERSION" | sed 's/^v//'`
|
VERSION=`echo "$VERSION" | sed 's/^v//'`
|
||||||
[ -n "$VERSION" ] && printf "%s" "$VERSION" > "$VERFILE"
|
[ -n "$VERSION" ] && printf "%s" "$VERSION" >"$VERFILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$VERFILE" ]
|
[ -f "$VERFILE" ] || printf "%s" "$DEF_VER" >"$VERFILE"
|
||||||
then
|
|
||||||
cat "$VERFILE"
|
|
||||||
else
|
|
||||||
echo "git-version-gen: unknown version number." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
cat "$VERFILE"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user