limine/version.sh

30 lines
523 B
Bash
Raw Normal View History

2022-01-21 04:24:36 +03:00
#! /bin/sh
2022-01-16 08:09:36 +03:00
LC_ALL=C
export LC_ALL
srcdir="$(dirname "$0")"
test -z "$srcdir" && srcdir=.
cd "$srcdir"
2024-02-06 11:27:21 +03:00
if [ -f version ]; then
printf '%s' "$(cat version)"
exit 0
fi
if ! [ -d .git ] || ! git log -n1 --pretty='%h' >/dev/null 2>&1; then
printf 'UNVERSIONED'
exit 0
fi
tmpfile="$(mktemp)"
if ! git describe --exact-match --tags $(git log -n1 --pretty='%h') >"$tmpfile" 2>/dev/null; then
echo g$(git log -n1 --pretty='%h') >"$tmpfile"
fi
printf '%s' "$(sed 's/^v//g' <"$tmpfile")"
rm -f "$tmpfile"