Skip to content

Commit

Permalink
Add the last Bazel version number to ./compile.sh
Browse files Browse the repository at this point in the history
All Bazel should now contain the latest version with a date
modifier to ensure we can track all Bazel builds out there.
It is especially important for bazelbuild#1014.

--
Change-Id: I8d17d9e1660b104c2b8623d5a8a06d010d044ea7
Reviewed-on: https://bazel-review.googlesource.com/3070
MOS_MIGRATED_REVID=117120584
  • Loading branch information
damienmg authored and dslomov committed Mar 14, 2016
1 parent 9f2c4f7 commit 28e67b5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fi
if [ "${EMBED_LABEL-x}" = "x" ]; then
# Add a default label when unspecified
git_sha1=$(git_sha1)
EMBED_LABEL="head (@${git_sha1:-non-git})"
EMBED_LABEL="$(get_last_version) (@${git_sha1:-non-git})"
fi

if [[ $PLATFORM == "darwin" ]] && \
Expand Down
21 changes: 21 additions & 0 deletions scripts/bootstrap/buildenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,27 @@ function git_sha1() {
fi
}

function git_date() {
if [ -x "$(which git || true)" ] && [ -d .git ]; then
git log -1 --pretty=%ai | cut -d " " -f 1 || true
fi
}

# Get the latest release version and append the date of
# the last commit if any.
function get_last_version() {
local version="$(fgrep -m 1 '## Release' CHANGELOG.md \
| sed -E 's|.*Release (.*) \(.*\)|\1|')"
local date="$(git_date)"
if [ -z "${version-}" ]; then
version="unknown"
fi
if [ -n "${date-}" ]; then
date="$(date +%Y-%m-%d)"
fi
echo "${version}-${date}"
}

if [[ ${PLATFORM} == "darwin" ]]; then
function md5_file() {
echo $(cat $1 | md5) $1
Expand Down

0 comments on commit 28e67b5

Please sign in to comment.