Skip to content

Commit

Permalink
Revise build number computation
Browse files Browse the repository at this point in the history
Use commits since last change to VERSION file instead of commits since
last tag. Build number is appended if VERSION ends in -dev or -pre. To
maintain consistency for 0.5.0-dev versions, the number of commits is
incremented by one for these (last tag was one commit before change to
VERSION).
  • Loading branch information
martinholters committed Jul 25, 2016
1 parent 8f99882 commit 06a5d8b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 11 deletions.
15 changes: 12 additions & 3 deletions base/version.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,18 @@ A `VersionNumber` object describing which version of Julia is in use. For detail
[Version Number Literals](:ref:`man-version-number-literals`).
"""
const VERSION = try
# Include build number if we've got at least some distance from a tag (e.g. a release)
build_number = GIT_VERSION_INFO.build_number != 0 ? "+$(GIT_VERSION_INFO.build_number)" : ""
convert(VersionNumber, "$(VERSION_STRING)$(build_number)")
ver = convert(VersionNumber, VERSION_STRING)
if !isempty(ver.prerelease)
build_number = GIT_VERSION_INFO.build_number
if ver == v"0.5.0-pre"
# due to change of reference for counting commits from last tag to last change of VERSION file
build_number += 5578
end
ver = VersionNumber(ver.major, ver.minor, ver.patch, ver.prerelease, (build_number,))
elseif GIT_VERSION_INFO.build_number != 0
println("WARNING: ignoring non-zero build number for VERSION")
end
ver
catch e
println("while creating Base.VERSION, ignoring error $e")
VersionNumber(0)
Expand Down
14 changes: 9 additions & 5 deletions base/version_git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ origin=$(git config -l 2>/dev/null | grep 'remote\.\w*\.url.*JuliaLang/julia.git
if [ -z "$origin" ]; then
origin="origin/"
fi
last_tag=$(git describe --tags --abbrev=0)
git_time=$(git log -1 --pretty=format:%ct)

#collect the contents
Expand All @@ -41,10 +40,15 @@ if [ -n "$(git status --porcelain)" ]; then
commit_short="$commit_short"*
fi
branch=$(git branch | sed -n '/\* /s///p')
# Some versions of wc (eg on OS X) add extra whitespace to their output.
# The sed(1) call stops this from breaking the generated Julia's indentation by
# stripping all non-digits.
build_number=$(git rev-list HEAD ^$last_tag | wc -l | sed -e 's/[^[:digit:]]//g')

topdir=$(git rev-parse --show-toplevel)
verchanged=$(git blame -L ,1 -sl -- "$topdir/VERSION" | cut -f 1 -d " ")
if [ $verchanged = 0000000000000000000000000000000000000000 ]; then
# uncommited change to VERSION
build_number=0
else
build_number=$(git rev-list --count HEAD "^$verchanged")
fi

date_string=$git_time
case $(uname) in
Expand Down
33 changes: 30 additions & 3 deletions contrib/commit-name.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,34 @@

gitref=${1:-HEAD}

last_tag=$(git describe --tags --abbrev=0 "$gitref")
ver=$(git show "$gitref:VERSION")
nb=$(git rev-list --count "$gitref" "^$last_tag")
echo "$ver+$nb"
major=$(echo $ver | cut -f 1 -d .)
minor=$(echo $ver | cut -f 2 -d .)

if [ $major = 0 -a $minor -lt 5 ]; then
# use tag based build number prior to 0.5.0-
last_tag=$(git describe --tags --abbrev=0 "$gitref")
nb=$(git rev-list --count "$gitref" "^$last_tag")
if [ $nb = 0 ]; then
echo $ver
else
echo "$ver+$nb"
fi
else
topdir=$(git rev-parse --show-toplevel)
verchanged=$(git blame -L ,1 -sl $gitref -- "$topdir/VERSION" | cut -f 1 -d " ")
nb=$(git rev-list --count "$gitref" "^$verchanged")
pre=$(echo $ver | cut -s -f 2 -d "-")
if [ $ver = "0.5.0-dev" ]; then
# bump to 0.5.0-dev was one commit after tag during 0.5.0-dev
nb=$(expr $nb + 1)
elif [ $ver = "0.5.0-pre" ]; then
# bump to 0.5.0-pre was 5578 commits after tag
nb=$(expr $nb + 5578)
fi
if [ -n "$pre" ]; then
echo "$ver+$nb"
else
echo $ver
fi
fi

0 comments on commit 06a5d8b

Please sign in to comment.