* Fix docs: choose_merge_request's open_reviewer default value is true (#316)
* Fix: Only set autocommands for select popups (#315)
* Docs: Small improvements to README and docs
* Feat: Add branch info to choose_merge_request menu (#318)

This is a PATCH release.
This commit is contained in:
Harrison (Harry) Cramer
2024-06-26 07:30:05 -07:00
committed by GitHub
parent 96d7e16ef7
commit 3c9d95d25b
6 changed files with 72 additions and 51 deletions

View File

@@ -29,6 +29,9 @@ To view these help docs and to get more detailed help information, please run `:
This will checkout the branch locally, and open the plugin's reviewer pane.
NOTE: At the moment, the plugin assumes that the remote where you want to merge your feature branch
is called "origin".
For more detailed information about the Lua APIs please run `:h gitlab.nvim.api`
## Installation

View File

@@ -55,6 +55,9 @@ QUICK START *gitlab.nvim.quick-start*
This will checkout the branch locally, and up the plugin's reviewer pane.
NOTE: At the moment, the plugin assumes that the remote where you want to
merge your feature branch is called "origin".
INSTALLATION *gitlab.nvim.installation*
@@ -83,7 +86,7 @@ And with Packer:
requires = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
"sindrets/diffview.nvim"
"sindrets/diffview.nvim",
"stevearc/dressing.nvim", -- Recommended but not required. Better UI for pickers.
"nvim-tree/nvim-web-devicons", -- Recommended but not required. Icons in discussion tree.
},
@@ -630,9 +633,10 @@ default arguments outlined under "Configuring the Plugin".
*gitlab.nvim.choose_merge_request*
gitlab.choose_merge_request({opts}) ~
Choose a merge request from a list of those open in your current project to review.
This command will automatically check out that branch locally, and optionally
open the reviewer pane. This is the default behavior.
Choose a merge request from a list of those open in your current project to
review. This command will automatically check out the feature branch locally,
and by default also open the reviewer pane (this can be overridden with the
`open_reviewer` parameter).
>lua
require("gitlab").choose_merge_request()
require("gitlab").choose_merge_request({ open_reviewer = false })

View File

@@ -316,8 +316,6 @@ M.create_mr = function()
forked_project_id = forked_project_id,
}
vim.print(body)
job.run_job("/create_mr", "POST", body, function(data)
u.notify(data.message, vim.log.levels.INFO)
M.reset_state()

View File

@@ -25,7 +25,7 @@ M.choose_merge_request = function(opts)
vim.ui.select(state.MERGE_REQUESTS, {
prompt = "Choose Merge Request",
format_item = function(mr)
return string.format("%s (%s)", mr.title, mr.author.name)
return string.format("%s [%s -> %s] (%s)", mr.title, mr.source_branch, mr.target_branch, mr.author.name)
end,
}, function(choice)
if not choice then

View File

@@ -63,10 +63,20 @@ M.summary = function()
description_popup,
M.edit_summary,
miscellaneous.attach_file,
{ cb = exit, action_before_close = true, save_to_temp_register = true }
{ cb = exit, action_before_close = true, action_before_exit = true, save_to_temp_register = true }
)
state.set_popup_keymaps(
title_popup,
M.edit_summary,
nil,
{ cb = exit, action_before_close = true, action_before_exit = true }
)
state.set_popup_keymaps(
info_popup,
M.edit_summary,
nil,
{ cb = exit, action_before_close = true, action_before_exit = true }
)
state.set_popup_keymaps(title_popup, M.edit_summary, nil, { cb = exit, action_before_close = true })
state.set_popup_keymaps(info_popup, M.edit_summary, nil, { cb = exit, action_before_close = true })
miscellaneous.set_cycle_popups_keymaps(popups)
vim.api.nvim_set_current_buf(description_popup.bufnr)
@@ -151,8 +161,6 @@ M.edit_summary = function()
u.notify(data.message, vim.log.levels.INFO)
state.INFO.description = data.mr.description
state.INFO.title = data.mr.title
M.layout:unmount()
M.layout_visible = false
end)
end

View File

@@ -295,9 +295,9 @@ M.set_popup_keymaps = function(popup, action, linewise_action, opts)
local text = u.get_buffer_text(popup.bufnr)
if opts.action_before_close then
action(text, popup.bufnr)
vim.api.nvim_buf_delete(popup.bufnr, {})
exit(popup, opts)
else
vim.api.nvim_buf_delete(popup.bufnr, {})
exit(popup, opts)
action(text, popup.bufnr)
end
end, { buffer = popup.bufnr, desc = "Perform action" })
@@ -312,19 +312,27 @@ M.set_popup_keymaps = function(popup, action, linewise_action, opts)
end, { buffer = popup.bufnr, desc = "Perform linewise action" })
end
if opts.save_to_temp_register then
vim.api.nvim_create_autocmd("BufWinLeave", {
buffer = popup.bufnr,
callback = function()
if opts.save_to_temp_register then
local text = u.get_buffer_text(popup.bufnr)
for _, register in ipairs(M.settings.popup.temp_registers) do
vim.fn.setreg(register, text)
end
end,
})
end
if opts.action_before_exit then
vim.api.nvim_create_autocmd("BufWinLeave", {
buffer = popup.bufnr,
callback = function()
exit(popup, opts)
end,
})
end
end
-- Dependencies
-- These tables are passed to the async.sequence function, which calls them in sequence