Files
todo.txt-cli/GEN-VERSION-FILE
a1346054 2d70a0aadf Minor fixes identified through shellcheck and other tools (#350)
* fix whitespace

* fix spelling

* fix whitespace

* unify headers of tests

* fix some issues in tests, identified by shellcheck

* fix bash completions

bash completion files are not supposed to be executable

* fix some issues identified by shellcheck

Co-authored-by: Ali Karbassi <ali@karbassi.com>
2021-08-09 15:03:49 -05:00

37 lines
568 B
Bash
Executable File

#!/bin/sh
# Based on git's GIT-VERSION-GEN.
VF=VERSION-FILE
DEF_VER=v2.2
LF='
'
if test -d .git -o -f .git &&
VN=$(git describe --abbrev=0 --tags 2>/dev/null) &&
case "$VN" in
*$LF*) (exit 1) ;;
v[0-9]*)
git update-index -q --refresh
test -z "$(git diff-index --name-only HEAD --)" ||
VN="$VN-dirty" ;;
esac
then
VN=$(echo "$VN" | sed -e 's/-/./g');
else
VN="$DEF_VER"
fi
VN=$(expr "$VN" : v*'\(.*\)')
if test -r $VF
then
VC=$(sed -e 's/^VERSION=//' <$VF)
else
VC=unset
fi
test "$VN" = "$VC" || {
echo >&2 "VERSION=$VN"
echo "VERSION=$VN" >$VF
}