| ... |
... |
@@ -44,22 +44,29 @@ else |
|
44
|
44
|
GIT_HASH="`echo ${GIT_DESC} | sed 's;^[^/]\+/;;' 2>/dev/null`"
|
|
45
|
45
|
BRANCH="`git rev-parse --abbrev-ref HEAD`*"
|
|
46
|
46
|
|
|
47
|
|
- if [ `expr "X$GIT_HASH" : 'Xsnapshot-[0-9][0-9][0-9][0-9]-[01][0-9]'` != 0 ]; then
|
|
48
|
|
- # The git hash looks like snapshot-yyyy-mm-<stuff>. Remove the
|
|
49
|
|
- # "snapshot-" part.
|
|
50
|
|
- DEFAULT_VERSION=`expr "$GIT_HASH" : "snapshot-\(.*\)"`
|
|
51
|
|
- elif [ `expr "X$GIT_HASH" : 'X[0-9][0-9][a-f]'` != 0 ]; then
|
|
52
|
|
- # The git hash looks like a release which is 3 hex digits. Use it as is.
|
|
53
|
|
- DEFAULT_VERSION="${GIT_HASH}"
|
|
54
|
|
- elif [ `expr "${GIT_HASH}" : "${BRANCH}"` != 0 ]; then
|
|
55
|
|
- # The hash looks like the current branch with possibly more
|
|
56
|
|
- # stuff at the end. Use the hash as the version.
|
|
57
|
|
- DEFAULT_VERSION="${GIT_HASH}"
|
|
58
|
|
- elif [ `expr "${GIT_HASH}" : "[0-9]*"` != 0 ]; then
|
|
59
|
|
- # Assuming this is CI which seems to produce a githash like
|
|
60
|
|
- # "pipeline/<digits>".
|
|
61
|
|
- DEFAULT_VERSION="${GIT_HASH}"
|
|
62
|
|
- fi
|
|
|
47
|
+ case "$GIT_HASH" in
|
|
|
48
|
+ snapshot-[0-9][0-9][0-9][0-9]-[01][0-9])
|
|
|
49
|
+ # The git hash looks like snapshot-yyyy-mm-<stuff>. Remove the
|
|
|
50
|
+ # "snapshot-" part.
|
|
|
51
|
+ DEFAULT_VERSION=`expr "$GIT_HASH" : "snapshot-\(.*\)"`
|
|
|
52
|
+ ;;
|
|
|
53
|
+ [0-9][0-9][a-f])
|
|
|
54
|
+ # The git hash looks like a release which is 3 hex digits.
|
|
|
55
|
+ # Use it as is.
|
|
|
56
|
+ DEFAULT_VERSION="${GIT_HASH}"
|
|
|
57
|
+ ;;
|
|
|
58
|
+ ${BRANCH}*)
|
|
|
59
|
+ # The hash looks like the current branch with possibly more
|
|
|
60
|
+ # stuff at the end. Use the hash as the version.
|
|
|
61
|
+ DEFAULT_VERSION="${GIT_HASH}"
|
|
|
62
|
+ ;;
|
|
|
63
|
+ [0-9]*)
|
|
|
64
|
+ # Assuming this is CI which seems to produce a githash like
|
|
|
65
|
+ # "pipeline/<digits>". Make the version include "ci-" so we
|
|
|
66
|
+ # know this was done via CI.
|
|
|
67
|
+ DEFAULT_VERSION="ci-${GIT_HASH}"
|
|
|
68
|
+ ;;
|
|
|
69
|
+ esac
|
|
63
|
70
|
|
|
64
|
71
|
if [ -z "$DEFAULT_VERSION" ]; then
|
|
65
|
72
|
echo "Unable to determine a default version from git describe: $GIT_DESC"
|