-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure-version
executable file
·51 lines (44 loc) · 945 Bytes
/
configure-version
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
#!/usr/bin/env bash
set -euo pipefail
top="$(pwd)"
readonly top
usage()
{
echo 'Usage: ./configure-version [--update | --clean]'
}
update-vpy()
{
declare -r vpy=lib/bup/_version.py
rm -f $vpy.tmp-$$
local hash date desc
hash=$(git log -1 --pretty=format:%H)
date=$(git log -1 --pretty=format:%ci)
desc=$(git describe --always --match="[0-9]*")
cat > $vpy.tmp-$$ <<-EOF
COMMIT='$hash'
NAMES='(tag: bup-$desc)'
DATE='$date'
EOF
if ! test -e $vpy || ! cmp -s $vpy $vpy.tmp-$$; then
mv $vpy.tmp-$$ $vpy;
fi
rm -f $vpy.tmp-$$
}
if test "$#" -ne 1; then
usage 1>&2; exit 1
fi
if ! test -f lib/bup/bupsplit.c; then
echo 'error: cannot find bup source tree' 1>&2
exit 1
fi
case "$1" in
--update)
update-vpy
;;
--clean)
rm -f lib/bup/_version.py lib/bup/_version.pyc lib/bup/_version.py.tmp-*
;;
*)
usage 1>&2; exit 1
;;
esac