forked from tgray/muttqt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.sh
executable file
·42 lines (38 loc) · 984 Bytes
/
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
36
37
38
39
40
41
42
#!/bin/sh -
if [[ ! -d ".git" ]]; then
# version=`cat VERSION | grep version | awk '{print $2}'`
commit=`cat VERSION | grep commit | awk '{print $2}'`
else
echo "Getting information from git"
describe=`git describe --long --dirty`
if [ -n "$describe" ]
then
version=`echo $describe | cut -d '-' -f1`
delta=`echo $describe | cut -d '-' -f2`
commit=`echo $describe | cut -d '-' -f3 | cut -c2-`
dirty=`echo $describe | cut -d '-' -f4`
else
version="0.0.0"
commit="None"
delta=""
dirty=""
fi
fi
if [ -n "$dirty" ]
then
commit="${commit}-d"
fi
if [ -f "$1" ]
then
echo "Modifying $1"
# sed -i .bak -E "s/^(__version__ = )\"([^\"]*)\"/\1\"${version}\"/" $1 || exit 3
sed -i .bak -E "s/^(__commit__ = )(None)$/\1\"${commit}\"/" $1 || exit 3
rm $1.bak
elif [ -z "$1" ]
then
echo "Must supply a file to modify"
exit 1
else
echo "File $1 does not exist"
exit 2
fi