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

feat(automerge): implement --merge-method flag for apply command #4895

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

a1k0u
Copy link

@a1k0u a1k0u commented Sep 4, 2024

what

Implemented flag which allows to specify merge method for the VCS (GitHub only for now) in automerge process.

atlantis apply --merge-method merge
atlantis apply --merge-method rebase
atlantis apply --merge-method squash

why

In our company Atlantis is using not only by DevOps/SRE/Ops Engineers, but also by lot of developers from other teams. They have different git commit message style, different way to split code changes into commits. Sometime we need to ask them to squash/rewrite commit message. These cause problems - after review developers force push changes (squash/rewrite commit message) and later start second atlantis plan which should be reviewed second time. Squash fix this, because the result commit message is PR title which can be change without any changes git history.

In old logic all methods except of squash can be off and that will fix previous case, but sometimes maintenance engineers work with big task where one pull request has several independent commits which be able to be revert after merge into master (rebase way)

So, these two cases are conflict with each other. We need to control merge method in automerge.

In our company, Atlantis is used not only by DevOps/SRE/Ops engineers, but also by many developers from other teams. They have a different style of git commit messages, a different way of dividing code changes into commits. Sometimes we need to ask them to squash commits/rewrite the commit message.

This causes problems - after first review, the developers force changes (squash commits/rewrite the commit message), and then start the second atlantis plan, which must be reviewed a second time. Squash fixes this because the result commit message is a PR header that can be changed without any changes to the git history.

In the old logic, all methods except squash can be disabled, and this will fix the previous case, but maintenance engineers often work with a large task where a single pull request contains several independent commits that can be revert after merging into master.

Thus, these two cases conflict with each other, because we need to use different merge strategies in different situations.
This can be fixed if any flag is able to control the merge method for automerge function.

tests

I have tested my changes by extend TestGithubClient_MergePullCorrectMethod. Added tests in which the --merge-method flag has the correct value, where correct value is not allowed and where value is not correct.

references

(opened issue) Automerge support for "require linear history" #1176
(opened issue) Feature Request: Allow Auto Merge with Squash or Rebase option #2047

@a1k0u a1k0u requested review from a team as code owners September 4, 2024 09:26
@a1k0u a1k0u requested review from GenPage, lukemassa and X-Guardian and removed request for a team September 4, 2024 09:26
@github-actions github-actions bot added docs Documentation go Pull requests that update Go code provider/github labels Sep 4, 2024
@chenrui333 chenrui333 added feature New functionality/enhancement and removed docs Documentation labels Sep 5, 2024
chenrui333
chenrui333 previously approved these changes Sep 12, 2024
@chenrui333
Copy link
Member

@a1k0u Thanks for implementing this feature. Looks like there is some conflict before merging the PR.

@a1k0u
Copy link
Author

a1k0u commented Sep 13, 2024

@chenrui333
Thank you for review! I've resolved the conflict

@a1k0u
Copy link
Author

a1k0u commented Sep 25, 2024

@chenrui333, hi! Can you review this PR again, please?

@a1k0u a1k0u force-pushed the specify-merge-method branch 2 times, most recently from 2d2aebe to 138d163 Compare October 7, 2024 14:40
@a1k0u
Copy link
Author

a1k0u commented Oct 7, 2024

@chenrui333 @jamengual @X-Guardian, hi! Can you review this PR again, please?

@a1k0u a1k0u force-pushed the specify-merge-method branch 2 times, most recently from 8054e51 to 022e7eb Compare October 11, 2024 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation feature New functionality/enhancement go Pull requests that update Go code provider/github
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants