diff options
Diffstat (limited to 'source/gen-version.sh')
| -rwxr-xr-x | source/gen-version.sh | 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 17 insertions, 17 deletions
diff --git a/source/gen-version.sh b/source/gen-version.sh index fb7d459..b28e987 100755 --- a/source/gen-version.sh +++ b/source/gen-version.sh @@ -1,27 +1,27 @@ #!/bin/sh +# Writes a "CGIT_VERSION = ..." line into the output file, which the build +# then includes. Run it from the project root, as gen-version.sh <fallback> +# [output], so that git describe reports cgit rather than the bundled git +# submodule. The output file defaults to VERSION. -# Writes a "CGIT_VERSION = ..." line to the output file (default: VERSION), -# for the build to include. Run from the project root so `git describe` acts -# on cgit rather than the bundled Git submodule. -# -# Usage: gen-version.sh <fallback-version> [output-file] +version=$1 +output=${2:-VERSION} -V=$1 -OUT=${2:-VERSION} - -# Prefer `git describe` when run at the top of the cgit working tree, -# keeping the fallback when it fails, as in a shallow tagless clone. +# Prefer what git describe reports, but only at the top of the cgit working +# tree, and keep the fallback when it has nothing to say, as in a shallow or +# tagless clone. if test "$(git rev-parse --git-dir 2>/dev/null)" = '.git' then - D=$(git describe --abbrev=4 HEAD 2>/dev/null) - test -n "$D" && V=$D + described=$(git describe --abbrev=4 HEAD 2>/dev/null) + test -n "$described" && version=$described fi -new="CGIT_VERSION = $V" -old=$(cat "$OUT" 2>/dev/null) +new="CGIT_VERSION = $version" +old=$(cat "$output" 2>/dev/null) -# Exit if the version is already up to date. +# Leaving the file untouched when nothing changed keeps make from rebuilding +# everything that depends on it. test "$old" = "$new" && exit 0 -echo "$new" > "$OUT" -cat "$OUT" +echo "$new" > "$output" +cat "$output" |
