Raymond Toy pushed to branch issue-464-lisp-version-uses-branch-name at cmucl / cmucl

Commits:

1 changed file:

Changes:

  • bin/git-version.sh
    ... ... @@ -36,37 +36,39 @@ if [ -n "$VERSION" ]; then
    36 36
         GIT_HASH="$VERSION"
    
    37 37
         DEFAULT_VERSION="$VERSION"
    
    38 38
     else
    
    39
    -    # The option --all allows use to use the the branch name or tag
    
    40
    -    # name as appropriate.  This is much more informative.  However,
    
    41
    -    # we have to remove everything before the first slash which
    
    42
    -    # contains things like "tag/" or "head/".
    
    43
    -    GIT_DESC="`git describe --all --dirty || git describe 2>/dev/null`"
    
    44
    -    GIT_HASH="`echo ${GIT_DESC} | sed 's;^[^/]*/;;' 2>/dev/null`"
    
    45
    -    BRANCH="`git rev-parse --abbrev-ref HEAD`*"
    
    39
    +    # Get the current branch.
    
    40
    +    BRANCH="`git rev-parse --abbrev-ref HEAD`"
    
    41
    +    if [ "$BRANCH" = "master" ]; then
    
    42
    +	# On the master branch, use simple git describe --dirty for the version
    
    43
    +	DEFAULT_VERSION="`git describe --all || git describe 2>/dev/null`"
    
    44
    +    else
    
    45
    +	# We're not on the master branch.  Do something different.
    
    46
    +	# The option --all allows use to use the the branch name or tag
    
    47
    +	# name as appropriate.  This is much more informative.  However,
    
    48
    +	# we have to remove everything before the first slash which
    
    49
    +	# contains things like "tag/" or "head/".
    
    50
    +	GIT_DESC="`git describe --all --dirty || git describe 2>/dev/null`"
    
    51
    +	GIT_HASH="`echo ${GIT_DESC} | sed 's;^[^/]*/;;' 2>/dev/null`"
    
    46 52
     
    
    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
    
    53
    +	case "$GIT_HASH" in
    
    54
    +	    snapshot-[0-9][0-9][0-9][0-9]-[01][0-9])
    
    55
    +		# The git hash looks like snapshot-yyyy-mm-<stuff>.  Remove the
    
    56
    +		# "snapshot-" part.
    
    57
    +		DEFAULT_VERSION=`expr "$GIT_HASH" : "snapshot-\(.*\)"`
    
    58
    +		;;
    
    59
    +	    [0-9][0-9][a-f])
    
    60
    +		# The git hash looks like a release which is 3 hex digits.
    
    61
    +		# Use it as is.
    
    62
    +		DEFAULT_VERSION="${GIT_HASH}"
    
    63
    +		;;
    
    64
    +	    [0-9]*)
    
    65
    +		# Assuming this is CI which seems to produce a githash like
    
    66
    +		# "pipeline/<digits>".  Make the version include "ci-" so we
    
    67
    +		# know this was done via CI.
    
    68
    +		DEFAULT_VERSION="ci-${GIT_HASH}"
    
    69
    +		;;
    
    70
    +	esac
    
    71
    +    fi
    
    70 72
     
    
    71 73
         if [ -z "$DEFAULT_VERSION" ]; then
    
    72 74
     	echo "Unable to determine a default version from git describe: $GIT_DESC"