Raymond Toy pushed to branch master at cmucl / cmucl Commits: 5c8a3b07 by Raymond Toy at 2026-06-27T06:45:04-07:00 Fix #464: Include branch name in the lisp version - - - - - c4b7b15f by Raymond Toy at 2026-06-27T06:45:05-07:00 Merge branch 'issue-464-lisp-version-uses-branch-name' into 'master' Fix #464: Include branch name in the lisp version Closes #464, #469, #470, #434, #466, #428, #459, and #463 See merge request cmucl/cmucl!343 - - - - - 2 changed files: - .gitlab-ci.yml - bin/git-version.sh Changes: ===================================== .gitlab-ci.yml ===================================== @@ -64,6 +64,7 @@ workflow: # Save this so we can see the generated errno - src/code/errno.lisp script: + - bin/git-version.sh # Do cross compile first #- bin/create-target.sh xtarget x86_linux_clang #- bin/create-target.sh xcross x86_linux_clang ===================================== bin/git-version.sh ===================================== @@ -8,7 +8,7 @@ git-version.sh [-hfv] -f The version is printed as a C file #define expression. Otherwise, the version is just printed to stdout - -v Use this as the version instead of using `git describe`, which + -v Use this as the version instead of using 'git describe', which is the default Determine the version of cmucl. By @@ -36,25 +36,60 @@ if [ -n "$VERSION" ]; then GIT_HASH="$VERSION" DEFAULT_VERSION="$VERSION" else - GIT_HASH="`(git describe --dirty 2>/dev/null || git describe 2>/dev/null)`" + # Get the current branch. + BRANCH="`git branch --show-current`" + if [ "$BRANCH" = "master" ]; then + # On the master branch, use simple git describe --dirty for the version + DEFAULT_VERSION="`git describe --dirty || git describe 2>/dev/null`" + elif [ -n "$BRANCH" ]; then + # We're on some branch. Just use the branch name. + DEFAULT_VERSION="$BRANCH" + else + # We're not on a branch. We need to do something different. + # The option --all allows use to use the the branch name or + # tag name as appropriate. This is much more informative. + # However, we have to remove everything before the first slash + # which contains things like "tags/", "head/", or "pipelines/" + # (from CI). + GIT_DESC="`git describe --dirty || git describe 2>/dev/null`" + GIT_HASH="`echo ${GIT_DESC} | sed 's;^[^/]*/;;' 2>/dev/null`" - if [ `expr "X$GIT_HASH" : 'Xsnapshot-[0-9][0-9][0-9][0-9]-[01][0-9]'` != 0 ]; then - # The git hash looks like snapshot-yyyy-mm-<stuff>. Remove the - # "snapshot-" part. - DEFAULT_VERSION=`expr "$GIT_HASH" : "snapshot-\(.*\)"` - elif [ `expr "X$GIT_HASH" : 'X[0-9][0-9][a-f]'` != 0 ]; then - # The git hash looks like a release which is 3 hex digits. Use it as is. - DEFAULT_VERSION="${GIT_HASH}" + case "$GIT_HASH" in + snapshot-[0-9][0-9][0-9][0-9]-[01][0-9]) + # The git hash looks like snapshot-yyyy-mm-<stuff>. Remove the + # "snapshot-" part. + DEFAULT_VERSION=`expr "$GIT_HASH" : "snapshot-\(.*\)"` + ;; + [0-9][0-9][a-f]) + # The git hash looks like a release which is 3 hex digits. + # Use it as is. + DEFAULT_VERSION="${GIT_HASH}" + ;; + [0-9][0-9][0-9][0-9][0-9]*) + # Assuming this is CI which seems to produce a githash like + # "pipeline/<digits>". Make the version include "ci-" so we + # know this was done via CI. + DEFAULT_VERSION="ci-${GIT_HASH}" + ;; + *) + # Use whatever we have. This handles the case where + # we're checked on some git hash. In that we we have + # "head/closest-branch-nn-gxxxxxx" where nn is the + # number of commits after the closest branch and + # xxxxxx is the git hash. + DEFAULT_VERSION="${GIT_HASH}" + ;; + esac fi if [ -z "$DEFAULT_VERSION" ]; then - echo "Unable to determine a default version from hash $GIT_HASH" + echo "Unable to determine a default version from git describe: $GIT_DESC" exit 1; fi fi if [ -z "$FILE" ]; then - echo $DEFAULT_VERSION + echo "$DEFAULT_VERSION" else cat <<EOF /* View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/3811161479e09f09331a9c1... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/3811161479e09f09331a9c1... You're receiving this email because of your account on gitlab.common-lisp.net. Manage all notifications: https://gitlab.common-lisp.net/-/profile/notifications | Help: https://gitlab.common-lisp.net/help