Update NEWS for v0.9.3
[cclive.git] / gen-ver.sh
blobcb6774006747e386dd9df9b5b7ee4df68e786d08
1 #!/bin/sh
3 # cclive
4 # Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
6 # This file is part of cclive <http://cclive.sourceforge.net/>.
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Affero General Public License as
10 # published by the Free Software Foundation, either version 3 of the
11 # License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Affero General Public License for more details.
18 # You should have received a copy of the GNU Affero General Public
19 # License along with this program. If not, see
20 # <http://www.gnu.org/licenses/>.
22 dir=`dirname $0`
24 # flags:
25 c= # strip off the 'v' prefix
27 # VERSION file is part of the dist tarball.
28 from_VERSION_file()
30 o=`cat "$dir/VERSION" 2>/dev/null`
33 from_git_describe()
35 [ -d "$dir/.git" -o -f "$dir/.git" ] && {
36 o=`git describe --match "v[0-9]*" --abbrev=4 HEAD 2>/dev/null`
40 dump_vn()
42 [ -n "$c" ] && o=${o#v} # strip off the 'v' prefix.
43 echo $o
44 exit 0
47 help()
49 echo "$0 [OPTIONS]
50 -h Show this help and exit
51 -c Strip off the 'v' prefix from the output"
52 exit 0
55 while [ $# -gt 0 ]
57 case "$1" in
58 -c) c=1;;
59 -h) help;;
60 *) break;;
61 esac
62 shift
63 done
65 from_VERSION_file
66 [ -z "$o" ] && from_git_describe
67 [ -n "$o" ] && dump_vn
68 exit 1
70 # vim: set ts=2 sw=2 tw=72 expandtab: