Skip to content

Commit acb75ca

Browse files
Merge pull request #26784 from Luap99/buildah-replace-test
test/buildah-bud: fix checkout to also handle go.mod replace
2 parents a9e80f9 + 9b62438 commit acb75ca

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

test/buildah-bud/run-buildah-bud-tests

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,20 @@ function die() {
8989
failhint=
9090
trap 'if [[ $? != 0 ]]; then if [[ -n $failhint ]]; then echo;echo "***************************************";echo "$failhint";echo;echo "Please see $BUD_TEST_DIR_REL/README.md for advice";fi;fi' 0
9191

92-
# Find the version of buildah we've vendored in, so we can run the right tests
93-
buildah_version=$(awk "\$1 == \"$BUILDAH_REPO\" { print \$2 }" <go.mod)
92+
# Find the version of buildah we've vendored in, so we can run the right tests.
93+
# Note first check if buildah is being replaced with a different version in which case we need to use that one.
94+
buildah_replace=$(go list -m -f '{{if .Replace}}{{.Replace}}{{end}}' $BUILDAH_REPO)
95+
buildah_checkout_repo="$BUILDAH_REPO"
96+
97+
if [[ -z "$buildah_replace" ]]; then
98+
# No replace this is fine, check the main version
99+
buildah_version=$(go list -m -f '{{.Version}}' $BUILDAH_REPO)
100+
else
101+
# replace string is "REPO VERSION" so split this into our two vars
102+
buildah_checkout_repo="${buildah_replace% *}"
103+
buildah_version="${buildah_replace#* }"
104+
fi
105+
94106

95107
if [[ -z "$buildah_version" ]]; then
96108
# This should not happen
@@ -147,7 +159,7 @@ if [[ -n $do_checkout ]]; then
147159
fi
148160

149161
failhint="'git clone' failed - this should never happen!"
150-
(set -x;git clone -q $shallow_checkout https://$BUILDAH_REPO $buildah_dir)
162+
(set -x;git clone -q $shallow_checkout https://$buildah_checkout_repo $buildah_dir)
151163

152164
# Recent versions of git (like `2.39`) disallow some operations (like `am`)
153165
# without an identity being set. In this case, git will throw an error
@@ -193,7 +205,7 @@ if [[ -n $do_checkout ]]; then
193205
# for a developer to push a new set of diffs to podman-land.
194206
failhint=
195207
sed -e "s,\[BASETAG\],${BASE_TAG},g" \
196-
-e "s,\[BUILDAHREPO\],${BUILDAH_REPO},g" \
208+
-e "s,\[BUILDAHREPO\],${buildah_checkout_repo},g" \
197209
< ${BUD_TEST_DIR}/make-new-buildah-diffs \
198210
> make-new-buildah-diffs
199211
chmod 755 make-new-buildah-diffs

0 commit comments

Comments
 (0)