xref: /dragonfly/tools/gitrev.sh (revision 19fe1c42)
1#!/bin/sh
2
3if ! which git >/dev/null 2>&1 ||
4	! cd "$(dirname "$0")" ||
5	! git rev-parse --git-dir >/dev/null 2>&1
6then
7	# XXX get version from newvers.sh?
8	echo "unknown"
9	exit 0
10fi
11
12v=$(git describe --abbrev=4 HEAD 2>/dev/null || git rev-parse --short HEAD)
13git update-index -q --refresh
14[ -z "$(git diff-index --name-only HEAD --)" ] || v="$v-dirty"
15
16v=$(echo "$v" | sed -e 's/-/./g;s/^v//;')
17
18echo "$v"
19exit 0
20