Skip to content

test/buildah-bud: fix checkout to also handle go.mod replace #26784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2025
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
20 changes: 16 additions & 4 deletions test/buildah-bud/run-buildah-bud-tests
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,20 @@ function die() {
failhint=
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

# Find the version of buildah we've vendored in, so we can run the right tests
buildah_version=$(awk "\$1 == \"$BUILDAH_REPO\" { print \$2 }" <go.mod)
# Find the version of buildah we've vendored in, so we can run the right tests.
# Note first check if buildah is being replaced with a different version in which case we need to use that one.
buildah_replace=$(go list -m -f '{{if .Replace}}{{.Replace}}{{end}}' $BUILDAH_REPO)
buildah_checkout_repo="$BUILDAH_REPO"

if [[ -z "$buildah_replace" ]]; then
# No replace this is fine, check the main version
buildah_version=$(go list -m -f '{{.Version}}' $BUILDAH_REPO)
else
# replace string is "REPO VERSION" so split this into our two vars
buildah_checkout_repo="${buildah_replace% *}"
buildah_version="${buildah_replace#* }"
fi


if [[ -z "$buildah_version" ]]; then
# This should not happen
Expand Down Expand Up @@ -147,7 +159,7 @@ if [[ -n $do_checkout ]]; then
fi

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

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