Skip to content
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

fix: use base branch from base repo instead of fork #4048

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

alanbover
Copy link
Contributor

@alanbover alanbover commented Dec 13, 2023

fix mergeAgain function for when the PR is created from a fork

what

Fixes #4034. When the PR is generated from a fork, mergeAgain function is incorrectly merging against baseBranch from the fork repository, instead of baseBranch from baseRepository.

why

mergeAgain() is called because merge strategy is enabled, and the workdir is not up to date with the last changes on the upstream repository base branch (origin) (https://github.com/alanbover/atlantis/blob/main/server/events/working_dir.go#L132)

Hence, mergeAgain() replicates the state from forceClone() https://github.com/alanbover/atlantis/blob/main/server/events/working_dir.go#L263. But note that head remote is added in a later step https://github.com/alanbover/atlantis/blob/main/server/events/working_dir.go#L272, hence the right place to clone from is origin.

tests

I have tested the changes building this locally, and it indeed fixes the problem

references

fix mergeAgain function for when the PR is created from a fork
@alanbover alanbover requested a review from a team as a code owner December 13, 2023 13:35
@github-actions github-actions bot added the go Pull requests that update Go code label Dec 13, 2023
@alanbover alanbover changed the title Update working_dir.go fix: update working_dir.go Dec 13, 2023
Copy link
Member

@GenPage GenPage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for catching this.

@GenPage GenPage enabled auto-merge (squash) December 13, 2023 14:50
@GenPage
Copy link
Member

GenPage commented Dec 13, 2023

/cherry-pick release-0.27

@GenPage GenPage added the bug Something isn't working label Dec 13, 2023
@GenPage GenPage merged commit da72b83 into runatlantis:main Dec 13, 2023
24 of 25 checks passed
gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Dec 13, 2023
fix mergeAgain function for when the PR is created from a fork
@nitrocode nitrocode changed the title fix: update working_dir.go fix: use base branch from base repo instead of fork Dec 18, 2023
lukemassa pushed a commit that referenced this pull request Dec 20, 2023
fix mergeAgain function for when the PR is created from a fork
lukemassa pushed a commit that referenced this pull request Dec 20, 2023
fix mergeAgain function for when the PR is created from a fork
lukemassa pushed a commit that referenced this pull request Dec 20, 2023
fix mergeAgain function for when the PR is created from a fork

Co-authored-by: Alan Bover <alanbover@gmail.com>
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
fix mergeAgain function for when the PR is created from a fork
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
fix mergeAgain function for when the PR is created from a fork
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

merge checkout strategy doesn't work correctly on re-plan if the commit comes from a fork
2 participants