feat(automerge): implement --merge-method flag for apply command #4895
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.
what
Implemented flag which allows to specify merge method for the VCS (GitHub only for now) in automerge process.
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.make test
references
(opened issue) Automerge support for "require linear history" #1176
(opened issue) Feature Request: Allow Auto Merge with Squash or Rebase option #2047