-
Notifications
You must be signed in to change notification settings - Fork 1
/
version.sh
executable file
·35 lines (32 loc) · 1.15 KB
/
version.sh
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
35
#!/bin/sh
# top-level version handler
#
# Copyright (c) 2018,2019 NIC.br <medicoes@simet.nic.br>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version. In every case, additional
# restrictions and permissions apply, refer to the COPYING file in the
# program Source for details.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License and the COPYING file in the program Source
# for details.
GIT_VER=
ME=$(realpath -q -e "$0")
BME=$(dirname "$ME")
exiterr() {
echo "unknown"
exit 1
}
cd "$BME" || exiterr
if $(git rev-parse --git-dir >/dev/null 2>&1) && [ -z "$(git rev-parse --show-prefix 2>/dev/null)" ] ; then
GIT_VER=$(git describe --dirty=+ --abbrev=10 --tags --long --match 'v*' --always 2>/dev/null)
fi
[ -z "$GIT_VER" ] && GIT_VER=$(cat version)
[ -z "$GIT_VER" ] && exiterr
echo "$GIT_VER"
: