summaryrefslogtreecommitdiff
path: root/checkversion
blob: b7193fc9b33d75a625015de820feebd30747dec7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env sh
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2021 Leah Rowe <leah@libreboot.org>

[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u

. "include/err.sh"

read project < projectname

version="version-unknown"
[ -f version ] && read version < version
version_="${version}"
if [ -e ".git" ]; then
	version="$(git describe --tags HEAD 2>&1)" || \
	    version="git-$(git rev-parse HEAD 2>&1)" || \
	    version="${version_}"
	printf "%s\n" "${version}" > version
fi

versiondate="version-date-unknown"
[ -f versiondate ] && read versiondate < versiondate
versiondate_="${versiondate}"
if [ -e ".git" ]; then
	versiondate="$(git show --no-patch --no-notes --pretty='%ct' HEAD)" || \
	    versiondate="${versiondate_}"
	printf "%s\n" "${versiondate}" > versiondate
fi

if [ "${versiondate}" = "version-date-unknown" ] || \
    [ "${version}" = "version-unknown" ]; then
	err "cannot determine ${projectname} revision"
fi