summaryrefslogtreecommitdiffstats
path: root/get-version.sh
blob: 49c7024144e7a4383ffb84ac89ed664056032bbd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

# Always create version string for repository this script lies in,
# not the cwd... Makes usage easier in cmake
ARG0="$0"
SELF="$(readlink -f "${ARG0}")"
ROOT_DIR="$(dirname "${SELF}")"
cd "$ROOT_DIR"

if [ -d .git ]; then
	[ -n "$(git diff HEAD)" ] && MODDED='+MOD'
	name="$( git describe )"
	[ -z "$name" ] && name="$( git rev-parse --short HEAD )"
	printf "%s\n" "$name$MODDED, branch $(git rev-parse --abbrev-ref HEAD), built $(date +%Y-%m-%d)"
	exit 0
fi

if [ -f "version.txt" ]; then
	cat "version.txt"
	exit 0
fi

echo "-unknown-"