forked from flecsi/flecsi
-
Notifications
You must be signed in to change notification settings - Fork 1
/
VERSION
executable file
·95 lines (81 loc) · 2.13 KB
/
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#! /usr/bin/env bash
cwd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [ -e $cwd/.git ] ; then
# Check for git on the system
git=`which git`
if [ "$git" = "" ] ; then
echo "ERROR! You must have git installed to use this script!!!"
exit
fi
detached=`git status --short --branch`
if [[ $detached =~ "no branch" ]]; then
describe=`cat $cwd/.version`
fi
tags=`git tag`
if [[ -n $tags ]]; then
describe=`git describe`
if [[ "$describe" != *"-"* ]]; then
describe="$describe-0-0"
fi
else
describe=`cat $cwd/.version`
fi
else
describe=`cat $cwd/.version`
fi
IFS='-'
read -ra DESCRIBE <<< "$describe"
if [ ${#DESCRIBE[*]} != 3 ]; then
echo "ERROR: invalid value returned by git describe"
exit 1
fi
sha=${DESCRIBE[2]}
# Devel branch
if [[ ${describe:0:1} == "d" ]]; then
version=`echo ${DESCRIBE[0]} | sed 's,d,,'`
IFS='.'
read -ra VERSION <<< "$version"
major=${VERSION[0]}
merge=${VERSION[1]}
commits=${DESCRIBE[1]}
if (( $commits > 0 )); then
echo "devel $major ($commits commits ahead at $sha,"\
"with $merge downstream merges)"
elif (( $merge > 1)); then
echo "devel $major ($merge downstream merges)"
else
echo "devel $major"
fi
# Feature branch
elif [[ ${describe:0:1} == "f" ]]; then
version=`echo ${DESCRIBE[0]} | sed 's,f,,'`
IFS='.'
read -ra VERSION <<< "$version"
major=${VERSION[0]}
minor=${VERSION[1]}
merge=${VERSION[2]}
commits=${DESCRIBE[1]}
if (( $commits > 0 )); then
echo "feature $major.$minor ($commits commits ahead at $sha,"\
"with $merge downstream merges)"
elif (( $merge > 1)); then
echo "feature $major.$minor ($merge downstream merges)"
else
echo "feature $major.$minor"
fi
# Release branch
elif [[ ${describe:0:1} == "v" ]]; then
release=${DESCRIBE[0]}
commits=${DESCRIBE[1]}
IFS='.'
read -ra RELEASE <<< "$release"
major=`echo ${RELEASE[0]} | sed 's,v,,'`
minor=${RELEASE[1]}
patch=${RELEASE[2]}
if (( $commits > 0 )); then
echo "release $major.$minor.$patch" \
"($commits commits ahead of tag at $sha)"
else
echo "release $major.$minor.$patch"
fi
fi