-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathversion.sh
More file actions
executable file
·20 lines (16 loc) · 865 Bytes
/
version.sh
File metadata and controls
executable file
·20 lines (16 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash
# This Source Code Form is licensed MPL-2.0: http://mozilla.org/MPL/2.0
set -Eeuo pipefail
# Commit information provided by git-archive in export-subst format string, see gitattributes(5)
read VDESCRIBE VDATE <<<' $Format: %(describe:match=v[0-9]*.[0-9]*.[0-9]*) %ci $ '
# Use baked-in version info if present
! [[ "$VDATE" =~ % ]] &&
echo "${VDESCRIBE#v} $VDATE" && exit
# Use version info from git repository, needs non-shallow clones
# Prefer exact tags (even if light, like nightly) over annotated tags
cd $(dirname $(readlink -f "$0"))
VDESCRIBE=$(git describe --exact-match --tags --match='v[0-9]*.[0-9]*.[0-9]*' 2>/dev/null ||
git describe --match='v[0-9]*.[0-9]*.[0-9]*' 2>/dev/null) &&
echo "${VDESCRIBE#v} `git -P log -1 --pretty=%ci`" && exit
# Fallback, unversioned
echo "0.0.0-unversioned0 2001-01-01 01:01:01 +0000"