Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion swift-ci/sdks/android/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,32 @@ function describe {
if [[ "${SWIFT_BUILD_DOCKER}" == "1" ]]; then
git config --global --add safe.directory $(pwd)
fi
git describe --tags

desc=$(git describe --tags)
extra=

# Although git describe is documented as returning the newest tag,
# if a given revision has multiple tags, it will actually return
# the first one it finds, so we have some more work to do here.

# If we aren't pointing directly at a tag, git describe will append
# -<number-of-commits>-g<truncated-hash> to the nearest tag. Strip
# this, but keep a note of it for later.
if [[ $desc =~ '-[0-9]+-g[0-9a-f]{11}$' ]]; then
stripped=${desc%-*-g*}
extra=${desc#$stripped}
desc=$stripped
fi

# Get the hash for the tag
rev=$(git rev-list -n 1 tags/$desc)

# Now find the newest tag at that hash, using version number ordering
latest_tag=$(git tag --points-at $rev | sort -V | tail -n 1)

# Stick it all back together
echo $latest_tag$extra

popd >/dev/null 2>&1
}
function versionFromTag {
Expand Down
Loading