| ... |
... |
@@ -8,7 +8,7 @@ git-version.sh [-hfv] |
|
8
|
8
|
-f The version is printed as a C file #define expression.
|
|
9
|
9
|
Otherwise, the version is just printed to stdout
|
|
10
|
10
|
|
|
11
|
|
- -v Use this as the version instead of using `git describe`, which
|
|
|
11
|
+ -v Use this as the version instead of using 'git describe', which
|
|
12
|
12
|
is the default
|
|
13
|
13
|
|
|
14
|
14
|
Determine the version of cmucl. By
|
| ... |
... |
@@ -36,25 +36,60 @@ if [ -n "$VERSION" ]; then |
|
36
|
36
|
GIT_HASH="$VERSION"
|
|
37
|
37
|
DEFAULT_VERSION="$VERSION"
|
|
38
|
38
|
else
|
|
39
|
|
- GIT_HASH="`(git describe --dirty 2>/dev/null || git describe 2>/dev/null)`"
|
|
|
39
|
+ # Get the current branch.
|
|
|
40
|
+ BRANCH="`git branch --show-current`"
|
|
|
41
|
+ if [ "$BRANCH" = "master" ]; then
|
|
|
42
|
+ # On the master branch, use simple git describe --dirty for the version
|
|
|
43
|
+ DEFAULT_VERSION="`git describe --dirty || git describe 2>/dev/null`"
|
|
|
44
|
+ elif [ -n "$BRANCH" ]; then
|
|
|
45
|
+ # We're on some branch. Just use the branch name.
|
|
|
46
|
+ DEFAULT_VERSION="$BRANCH"
|
|
|
47
|
+ else
|
|
|
48
|
+ # We're not on a branch. We need to do something different.
|
|
|
49
|
+ # The option --all allows use to use the the branch name or
|
|
|
50
|
+ # tag name as appropriate. This is much more informative.
|
|
|
51
|
+ # However, we have to remove everything before the first slash
|
|
|
52
|
+ # which contains things like "tags/", "head/", or "pipelines/"
|
|
|
53
|
+ # (from CI).
|
|
|
54
|
+ GIT_DESC="`git describe --dirty || git describe 2>/dev/null`"
|
|
|
55
|
+ GIT_HASH="`echo ${GIT_DESC} | sed 's;^[^/]*/;;' 2>/dev/null`"
|
|
40
|
56
|
|
|
41
|
|
- if [ `expr "X$GIT_HASH" : 'Xsnapshot-[0-9][0-9][0-9][0-9]-[01][0-9]'` != 0 ]; then
|
|
42
|
|
- # The git hash looks like snapshot-yyyy-mm-<stuff>. Remove the
|
|
43
|
|
- # "snapshot-" part.
|
|
44
|
|
- DEFAULT_VERSION=`expr "$GIT_HASH" : "snapshot-\(.*\)"`
|
|
45
|
|
- elif [ `expr "X$GIT_HASH" : 'X[0-9][0-9][a-f]'` != 0 ]; then
|
|
46
|
|
- # The git hash looks like a release which is 3 hex digits. Use it as is.
|
|
47
|
|
- DEFAULT_VERSION="${GIT_HASH}"
|
|
|
57
|
+ case "$GIT_HASH" in
|
|
|
58
|
+ snapshot-[0-9][0-9][0-9][0-9]-[01][0-9])
|
|
|
59
|
+ # The git hash looks like snapshot-yyyy-mm-<stuff>. Remove the
|
|
|
60
|
+ # "snapshot-" part.
|
|
|
61
|
+ DEFAULT_VERSION=`expr "$GIT_HASH" : "snapshot-\(.*\)"`
|
|
|
62
|
+ ;;
|
|
|
63
|
+ [0-9][0-9][a-f])
|
|
|
64
|
+ # The git hash looks like a release which is 3 hex digits.
|
|
|
65
|
+ # Use it as is.
|
|
|
66
|
+ DEFAULT_VERSION="${GIT_HASH}"
|
|
|
67
|
+ ;;
|
|
|
68
|
+ [0-9][0-9][0-9][0-9][0-9]*)
|
|
|
69
|
+ # Assuming this is CI which seems to produce a githash like
|
|
|
70
|
+ # "pipeline/<digits>". Make the version include "ci-" so we
|
|
|
71
|
+ # know this was done via CI.
|
|
|
72
|
+ DEFAULT_VERSION="ci-${GIT_HASH}"
|
|
|
73
|
+ ;;
|
|
|
74
|
+ *)
|
|
|
75
|
+ # Use whatever we have. This handles the case where
|
|
|
76
|
+ # we're checked on some git hash. In that we we have
|
|
|
77
|
+ # "head/closest-branch-nn-gxxxxxx" where nn is the
|
|
|
78
|
+ # number of commits after the closest branch and
|
|
|
79
|
+ # xxxxxx is the git hash.
|
|
|
80
|
+ DEFAULT_VERSION="${GIT_HASH}"
|
|
|
81
|
+ ;;
|
|
|
82
|
+ esac
|
|
48
|
83
|
fi
|
|
49
|
84
|
|
|
50
|
85
|
if [ -z "$DEFAULT_VERSION" ]; then
|
|
51
|
|
- echo "Unable to determine a default version from hash $GIT_HASH"
|
|
|
86
|
+ echo "Unable to determine a default version from git describe: $GIT_DESC"
|
|
52
|
87
|
exit 1;
|
|
53
|
88
|
fi
|
|
54
|
89
|
fi
|
|
55
|
90
|
|
|
56
|
91
|
if [ -z "$FILE" ]; then
|
|
57
|
|
- echo $DEFAULT_VERSION
|
|
|
92
|
+ echo "$DEFAULT_VERSION"
|
|
58
|
93
|
else
|
|
59
|
94
|
cat <<EOF
|
|
60
|
95
|
/*
|