This repository has been archived by the owner on Sep 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgen-ver.sh
executable file
·70 lines (63 loc) · 1.5 KB
/
gen-ver.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
#
# quvi
# Copyright (C) 2012 Toni Gundogdu <[email protected]>
#
# This file is part of libquvi <http://quvi.sourceforge.net/>.
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public
# License as published by the Free Software Foundation, either
# version 3 of the License, or (at your option) any later version.
#
# 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General
# Public License along with this program. If not, see
# <http://www.gnu.org/licenses/>.
#
dir=`dirname $0`
o=
# flags:
c= # strip off the 'v' prefix
# VERSION file is part of the dist tarball.
from_VERSION_file()
{
o=`cat "$dir/VERSION" 2>/dev/null`
}
from_git_describe()
{
[ -d "$dir/.git" -o -f "$dir/.git" ] && {
o=`git describe --match "v[0-9]*" --abbrev=4 HEAD 2>/dev/null`
}
}
dump_vn()
{
[ -n "$c" ] && o=${o#v} # strip off the 'v' prefix.
echo $o
exit 0
}
help()
{
echo "$0 [OPTIONS]
-h Show this help and exit
-c Strip off the 'v' prefix from the output"
exit 0
}
while [ $# -gt 0 ]
do
case "$1" in
-c) c=1;;
-h) help;;
*) break;;
esac
shift
done
from_VERSION_file
[ -z "$o" ] && from_git_describe
[ -n "$o" ] && dump_vn
exit 1
# vim: set ts=2 sw=2 tw=72 expandtab: