Skip to content

Commit 3c9d95d

Browse files
Release (#313)
* 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.
1 parent 96d7e16 commit 3c9d95d

File tree

6 files changed

+72
-51
lines changed

6 files changed

+72
-51
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ To view these help docs and to get more detailed help information, please run `:
2929

3030
This will checkout the branch locally, and open the plugin's reviewer pane.
3131

32+
NOTE: At the moment, the plugin assumes that the remote where you want to merge your feature branch
33+
is called "origin".
34+
3235
For more detailed information about the Lua APIs please run `:h gitlab.nvim.api`
3336

3437
## Installation

doc/gitlab.nvim.txt

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ QUICK START *gitlab.nvim.quick-start*
5555

5656
This will checkout the branch locally, and up the plugin's reviewer pane.
5757

58+
NOTE: At the moment, the plugin assumes that the remote where you want to
59+
merge your feature branch is called "origin".
60+
5861

5962
INSTALLATION *gitlab.nvim.installation*
6063

@@ -78,25 +81,25 @@ With Lazy:
7881
<
7982
And with Packer:
8083
>lua
81-
use {
82-
"harrisoncramer/gitlab.nvim",
83-
requires = {
84-
"MunifTanjim/nui.nvim",
85-
"nvim-lua/plenary.nvim",
86-
"sindrets/diffview.nvim"
87-
"stevearc/dressing.nvim", -- Recommended but not required. Better UI for pickers.
88-
"nvim-tree/nvim-web-devicons", -- Recommended but not required. Icons in discussion tree.
89-
},
90-
build = function()
91-
require("gitlab.server").build()
92-
end,
93-
branch = "develop",
94-
config = function()
95-
require("diffview") -- We require some global state from diffview
96-
local gitlab = require("gitlab")
97-
gitlab.setup()
98-
end,
99-
}
84+
use {
85+
"harrisoncramer/gitlab.nvim",
86+
requires = {
87+
"MunifTanjim/nui.nvim",
88+
"nvim-lua/plenary.nvim",
89+
"sindrets/diffview.nvim",
90+
"stevearc/dressing.nvim", -- Recommended but not required. Better UI for pickers.
91+
"nvim-tree/nvim-web-devicons", -- Recommended but not required. Icons in discussion tree.
92+
},
93+
build = function()
94+
require("gitlab.server").build()
95+
end,
96+
branch = "develop",
97+
config = function()
98+
require("diffview") -- We require some global state from diffview
99+
local gitlab = require("gitlab")
100+
gitlab.setup()
101+
end,
102+
}
100103
<
101104

102105
CONNECTING TO GITLAB *gitlab.nvim.connecting-to-gitlab*
@@ -418,18 +421,18 @@ SIGNS AND DIAGNOSTICS *gitlab.nvim.signs-and-diagnostics*
418421
By default when reviewing files, you will see diagnostics for comments that
419422
have been added to a review. These are the default settings:
420423
>lua
421-
discussion_signs = {
422-
enabled = true, -- Show diagnostics for gitlab comments in the reviewer
423-
skip_resolved_discussion = false, -- Show diagnostics for resolved discussions
424-
severity = vim.diagnostic.severity.INFO, -- ERROR, WARN, INFO, or HINT
425-
virtual_text = false, -- Whether to show the comment text inline as floating virtual text
426-
use_diagnostic_signs = true, -- Show diagnostic sign (depending on the `severity` setting, e.g., I for INFO) along with the comment icon
427-
priority = 100, -- Higher will override LSP warnings, etc
428-
icons = {
429-
comment = "→|",
430-
range = " |",
424+
discussion_signs = {
425+
enabled = true, -- Show diagnostics for gitlab comments in the reviewer
426+
skip_resolved_discussion = false, -- Show diagnostics for resolved discussions
427+
severity = vim.diagnostic.severity.INFO, -- ERROR, WARN, INFO, or HINT
428+
virtual_text = false, -- Whether to show the comment text inline as floating virtual text
429+
use_diagnostic_signs = true, -- Show diagnostic sign (depending on the `severity` setting, e.g., I for INFO) along with the comment icon
430+
priority = 100, -- Higher will override LSP warnings, etc
431+
icons = {
432+
comment = "→|",
433+
range = " |",
434+
},
431435
},
432-
},
433436

434437
When the cursor is on a diagnostic line you can view the discussion thread by
435438
using `vim.diagnostic.show()`.
@@ -630,9 +633,10 @@ default arguments outlined under "Configuring the Plugin".
630633
*gitlab.nvim.choose_merge_request*
631634
gitlab.choose_merge_request({opts}) ~
632635

633-
Choose a merge request from a list of those open in your current project to review.
634-
This command will automatically check out that branch locally, and optionally
635-
open the reviewer pane. This is the default behavior.
636+
Choose a merge request from a list of those open in your current project to
637+
review. This command will automatically check out the feature branch locally,
638+
and by default also open the reviewer pane (this can be overridden with the
639+
`open_reviewer` parameter).
636640
>lua
637641
require("gitlab").choose_merge_request()
638642
require("gitlab").choose_merge_request({ open_reviewer = false })

lua/gitlab/actions/create_mr.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,6 @@ M.create_mr = function()
316316
forked_project_id = forked_project_id,
317317
}
318318

319-
vim.print(body)
320-
321319
job.run_job("/create_mr", "POST", body, function(data)
322320
u.notify(data.message, vim.log.levels.INFO)
323321
M.reset_state()

lua/gitlab/actions/merge_requests.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ M.choose_merge_request = function(opts)
2525
vim.ui.select(state.MERGE_REQUESTS, {
2626
prompt = "Choose Merge Request",
2727
format_item = function(mr)
28-
return string.format("%s (%s)", mr.title, mr.author.name)
28+
return string.format("%s [%s -> %s] (%s)", mr.title, mr.source_branch, mr.target_branch, mr.author.name)
2929
end,
3030
}, function(choice)
3131
if not choice then

lua/gitlab/actions/summary.lua

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,20 @@ M.summary = function()
6363
description_popup,
6464
M.edit_summary,
6565
miscellaneous.attach_file,
66-
{ cb = exit, action_before_close = true, save_to_temp_register = true }
66+
{ cb = exit, action_before_close = true, action_before_exit = true, save_to_temp_register = true }
67+
)
68+
state.set_popup_keymaps(
69+
title_popup,
70+
M.edit_summary,
71+
nil,
72+
{ cb = exit, action_before_close = true, action_before_exit = true }
73+
)
74+
state.set_popup_keymaps(
75+
info_popup,
76+
M.edit_summary,
77+
nil,
78+
{ cb = exit, action_before_close = true, action_before_exit = true }
6779
)
68-
state.set_popup_keymaps(title_popup, M.edit_summary, nil, { cb = exit, action_before_close = true })
69-
state.set_popup_keymaps(info_popup, M.edit_summary, nil, { cb = exit, action_before_close = true })
7080
miscellaneous.set_cycle_popups_keymaps(popups)
7181

7282
vim.api.nvim_set_current_buf(description_popup.bufnr)
@@ -151,8 +161,6 @@ M.edit_summary = function()
151161
u.notify(data.message, vim.log.levels.INFO)
152162
state.INFO.description = data.mr.description
153163
state.INFO.title = data.mr.title
154-
M.layout:unmount()
155-
M.layout_visible = false
156164
end)
157165
end
158166

lua/gitlab/state.lua

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,9 @@ M.set_popup_keymaps = function(popup, action, linewise_action, opts)
295295
local text = u.get_buffer_text(popup.bufnr)
296296
if opts.action_before_close then
297297
action(text, popup.bufnr)
298-
vim.api.nvim_buf_delete(popup.bufnr, {})
298+
exit(popup, opts)
299299
else
300-
vim.api.nvim_buf_delete(popup.bufnr, {})
300+
exit(popup, opts)
301301
action(text, popup.bufnr)
302302
end
303303
end, { buffer = popup.bufnr, desc = "Perform action" })
@@ -312,18 +312,26 @@ M.set_popup_keymaps = function(popup, action, linewise_action, opts)
312312
end, { buffer = popup.bufnr, desc = "Perform linewise action" })
313313
end
314314

315-
vim.api.nvim_create_autocmd("BufWinLeave", {
316-
buffer = popup.bufnr,
317-
callback = function()
318-
if opts.save_to_temp_register then
315+
if opts.save_to_temp_register then
316+
vim.api.nvim_create_autocmd("BufWinLeave", {
317+
buffer = popup.bufnr,
318+
callback = function()
319319
local text = u.get_buffer_text(popup.bufnr)
320320
for _, register in ipairs(M.settings.popup.temp_registers) do
321321
vim.fn.setreg(register, text)
322322
end
323-
end
324-
exit(popup, opts)
325-
end,
326-
})
323+
end,
324+
})
325+
end
326+
327+
if opts.action_before_exit then
328+
vim.api.nvim_create_autocmd("BufWinLeave", {
329+
buffer = popup.bufnr,
330+
callback = function()
331+
exit(popup, opts)
332+
end,
333+
})
334+
end
327335
end
328336

329337
-- Dependencies

0 commit comments

Comments
 (0)