feat!: implement AutoMerge option to AcceptMergeRequest#530
Open
jakubbortlik wants to merge 4 commits intoharrisoncramer:developfrom
Open
feat!: implement AutoMerge option to AcceptMergeRequest#530jakubbortlik wants to merge 4 commits intoharrisoncramer:developfrom
jakubbortlik wants to merge 4 commits intoharrisoncramer:developfrom
Conversation
…r#518 This PR also fixes a bug when the `Delete source branch` setting of the MR was not respected due to incorrect reference in `lua/gitlab/actions/merge.lua` to `state.INFO.delete_branch` instead of `state.INFO.force_remove_source_branch`. This PR also changes the behaviour of how the `opts` in `gitlab.merge(opts)` behave: - Before this PR: - when `lua require("gitlab").merge()` was run without parameters, the values visible in the Summary view were used (except for the bug mentioned above). - specifying one of `squash` or `delete_branch` in `opts` caused the other parameter to default to `false` even if Summary view would show it's set to `true`. - After this PR: - running `lua require("gitlab").merge()` without parameters doesn't change. - specifying any of the `opts` values (`auto_merge`, `squash`, `delete_branch`), has no effect on the other options - if not specified in the `gitlab.merge()` call, the values from the Summary are used. This is a breaking change, since theoretically, before, a user could rely on the fact that ignoring one of the options would set it to `false` which now is not guaranteed (the value depends on the existing MR settings).
jakubbortlik
commented
Feb 23, 2026
Comment on lines
27
to
45
| if state.INFO.detailed_merge_status ~= "mergeable" then | ||
| if state.INFO.detailed_merge_status ~= "mergeable" and not merge_body.auto_merge then | ||
| u.notify(string.format("MR not mergeable, currently '%s'", state.INFO.detailed_merge_status), vim.log.levels.ERROR) | ||
| return | ||
| end | ||
|
|
||
| if merge_body.squash then | ||
| local squash_message_popup = create_squash_message_popup() | ||
| popup.set_up_autocommands(squash_message_popup, nil, vim.api.nvim_get_current_win()) | ||
| squash_message_popup:mount() | ||
| popup.set_popup_keymaps(squash_message_popup, function(text) | ||
| M.confirm_merge(merge_body, text) | ||
| end, nil, popup.editable_popup_opts) | ||
| else | ||
| M.confirm_merge(merge_body) | ||
| end |
Collaborator
Author
There was a problem hiding this comment.
I'm thinking about adding this vim.ui.select call with a recursive call to M.merge, which would make it simpler for users to set auto-merge, but maybe it's a pattern that you (@harrisoncramer) don't want to introduce in the codebase.
if state.INFO.detailed_merge_status ~= "mergeable" and not merge_body.auto_merge then
vim.ui.select({ "Set auto-merge", "Cancel" }, {
prompt = string.format(
"MR not mergeable (currently '%s'). Set auto-merge instead?",
state.INFO.detailed_merge_status
),
}, function(choice)
if choice == "Set auto-merge" then
local opts_ = opts or {}
opts_.auto_merge = true
M.merge(opts_) -- Recurse here with overridden `auto_merge`
end
end)
else
if merge_body.squash then
local squash_message_popup = create_squash_message_popup()
popup.set_up_autocommands(squash_message_popup, nil, vim.api.nvim_get_current_win())
squash_message_popup:mount()
popup.set_popup_keymaps(squash_message_popup, function(text)
M.confirm_merge(merge_body, text)
end, nil, popup.editable_popup_opts)
else
M.confirm_merge(merge_body)
end
end
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.
Closes #518.
This PR also fixes a bug when the
Delete source branchsetting of the MR was not respected due to incorrect reference inlua/gitlab/actions/merge.luatostate.INFO.delete_branchinstead ofstate.INFO.force_remove_source_branch.This PR also changes the behaviour of how the
optsingitlab.merge(opts)behave:Before this PR:
lua require("gitlab").merge()was run without parameters, the values visible in the Summary view were used (except for the bug mentioned above).squashordelete_branchinoptscaused the other parameter to default tofalseeven if Summary view would show it's set totrue.After this PR:
lua require("gitlab").merge()without parameters doesn't change.optsvalues (auto_merge,squash,delete_branch), has no effect on the other options - if not specified in thegitlab.merge()call, the values from the Summary are used.This is a breaking change since before, a user could rely on the fact that ignoring one of the options would set it to
falsewhich now is not guaranteed - the value depends on the existing MR settings, which I find to be the desirable behaviour: