[backport] Keep backport branch's own .go-version during branch creation - #20469
Draft
mrodm wants to merge 4 commits into
Draft
[backport] Keep backport branch's own .go-version during branch creation#20469mrodm wants to merge 4 commits into
mrodm wants to merge 4 commits into
Conversation
Instead of overwriting .go-version from the source branch, activate the backport branch's Go version via gvm before running go mod tidy so that go.mod stays consistent with the branch's toolchain requirement. Restore the source branch Go version afterward for the rest of the script. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This reverts commit 596a953.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed commit message
WHAT:
The
backport_branch.shscript previously forced-copied.go-versionfrom the source branch (main) into the backport branch before runninggo mod tidy. This silently overwrote the backport branch's Go version, meaning all backport branches ended up with main's Go version — even when they were intentionally pinned to an older one.The fix removes that forced copy and instead activates the backport branch's own
.go-versionviagvmbefore runninggo mod tidy, so thatgo.modis tidied against the correct toolchain. Aftergo mod tidycompletes, the source branch Go version is restored for the rest of the script.WHY:
Backport branches targeting older release lines may need to pin an older Go version. Overwriting
.go-versionfrom main breaks that invariant and can causego mod tidyto produce ago.modthat is incompatible with the toolchain the backport branch is actually meant to use.Example of errors:
Author's Checklist
gvmis available in all Buildkite agent environments where this script runs.go mod tidy.Buildkite build testing this: https://buildkite.com/elastic/integrations-backport/builds/318
How to test this PR locally
.go-versionthanmain..go-versionon the resulting branch still reflects the backport branch's original version.go.modis updated correctly bygo mod tidywithout changing thegodirective to a newer version.Related issues