Skip to content

Commit 8e9cd7f

Browse files
committed
Fix git command to retrieve commit matching the tag
To find the correct binary to use for the build when a user checks out a tag, we need to match the exact commit for the tag. `git tag --contains` would list all the tags containing the commit, but we need to verify that the commit we're on matches the current tag.
1 parent 6b41889 commit 8e9cd7f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

hack/docker.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ git_commit=$1
44
git_tag=$2
55
docker_tag=edge
66

7-
commit_tag=$(git tag --contains ${git_commit})
7+
commit_tag=$(git describe --exact-match ${git_commit} 2>/dev/null)
88

9-
if [[ ${commit_tag} == *${git_tag}* ]]; then
10-
# we're on the tag, use the docker image for the tag
9+
if [[ ${commit_tag} == ${git_tag} ]]; then
10+
# we're on the exact commit of the tag, use the docker image for the tag
1111
docker_tag=${git_tag//v/}
1212
echo ${docker_tag}
1313
exit 0
1414

1515
else
16-
# we're on main or a branch, try to download the latest edge and see if sha matches
16+
# we're on a random commit, pull the 'edge' docker image to compare commits
17+
# if it's the latest commit from 'main' the SHA will match the 'revision' of the 'edge' docker image
1718
docker pull nginx/nginx-ingress:${docker_tag} >/dev/null 2>&1
1819
DOCKER_SHA=$(docker inspect --format '{{ index .Config.Labels "org.opencontainers.image.revision" }}' nginx/nginx-ingress:${docker_tag})
1920
if [[ ${DOCKER_SHA} == ${git_commit} ]]; then

0 commit comments

Comments
 (0)