Squash instead of merge commit
simenandre opened this issue Β· comments
Hello π
Thank you for this awesome project! I'd love to contribute to this project, and one thing that has bugged me a little is that I have no way to choose which kind of merge I'd like.
I would rather squash and merge than add a merge commit. I'm not sure if it's possible, but I'd love to have a go at it if that is a feature you'd like to see in Microplane!
Thanks again!
Thanks so much for the suggestion! Yes, I think that is possible, and it would be a nice feature if you'd like to add it.
I imagine usage would look something like
$ mp merge --merge-method squash ...
Here's how I'd go about adding it...
The backend logic for merging happens here
Lines 97 to 102 in 9487433
You'd want to set mergeMethod: "squash"
within the PullRequestOptions
(see `go-github: https://github.com/google/go-github/blob/a0bec87ef51b4d7f14371d355986c7ca8cd0d84c/github/pulls.go#L440-L441)
Beyond that, we'd want to make sure it's configurable from the CLI command. We can set the merge method via a flag, and default to the existing behavior.
Lines 33 to 36 in 9487433
Lines 18 to 21 in da8630b
@nathanleiby thank you for the quick reply. I've opened a pull request, hopefully, that works out? :)
See #105
@cobraz Thanks for adding support for this feature!
I realize that we could also add this feature for Gitlab. Sharing some relevant info below, in case you or someone else would like to add it.
During merge, it seems that Gitlab supports merge
(default) or squash
. rebase
isn't handled as a 3rd merge option, but instead must be done separately from the merge.
- https://pkg.go.dev/github.com/xanzy/go-gitlab#MergeRequestsService.AcceptMergeRequest
- https://docs.gitlab.com/ee/api/merge_requests.html#accept-mr
Today in Microplane's Gitlab logic...
If a rebase is possible, we will always do it before merging:
microplane/merge/mergeGitlab.go
Lines 67 to 73 in bc56dbb
We do the merge here (this is where we could pass squash: true
as an option):
microplane/merge/mergeGitlab.go
Lines 78 to 80 in bc56dbb
Suggested Gitlab approach, to give squash support without breaking anything existing:
- always rebase for Gitlab (keep existing behavior)
- if
mergeOption == squash
, thensquash: true
, otherwisesquash: false
Re-opening to track the remaining Gitlab work