Small bug fixes (#298)

fix: List remote branches for merge targets (#293)
fix: consider remote branches (#297)
fix: Save popup contents to temp_registers (#294) 

This is a #PATCH release.
This commit is contained in:
Harrison (Harry) Cramer
2024-05-05 11:12:39 -04:00
committed by GitHub
parent 0d0ed1639a
commit 816b87cf91
5 changed files with 21 additions and 14 deletions

View File

@@ -188,28 +188,23 @@ M.create_comment_layout = function(opts)
},
}, internal_layout)
local popup_opts = {
action_before_close = true,
action_before_exit = false,
}
miscellaneous.set_cycle_popups_keymaps({ M.comment_popup, M.draft_popup })
local range = opts.ranged and { start_line = M.start_line, end_line = M.end_line } or nil
local unlinked = opts.unlinked or false
---Keybinding for focus on text section
---Keybinding for focus on draft section
state.set_popup_keymaps(M.draft_popup, function()
local text = u.get_buffer_text(M.comment_popup.bufnr)
confirm_create_comment(text, range, unlinked, opts.discussion_id)
vim.api.nvim_set_current_win(M.current_win)
end, miscellaneous.toggle_bool, popup_opts)
end, miscellaneous.toggle_bool, miscellaneous.non_editable_popup_opts)
---Keybinding for focus on draft section
---Keybinding for focus on text section
state.set_popup_keymaps(M.comment_popup, function(text)
confirm_create_comment(text, range, unlinked, opts.discussion_id)
vim.api.nvim_set_current_win(M.current_win)
end, miscellaneous.attach_file, popup_opts)
end, miscellaneous.attach_file, miscellaneous.editable_popup_opts)
vim.schedule(function()
local draft_mode = state.settings.discussion_tree.draft_mode

View File

@@ -113,7 +113,7 @@ end
---@param tree NuiTree
M.copy_node_url = function(tree)
local url = M.get_url(tree)
if url == nil then
if url ~= nil then
vim.fn.setreg("+", url)
u.notify("Copied '" .. url .. "' to clipboard", vim.log.levels.INFO)
end

View File

@@ -35,9 +35,17 @@ M.attach_file = function()
end
M.editable_popup_opts = {
action_before_close = true,
action_before_exit = false,
save_to_temp_register = true,
}
M.non_editable_popup_opts = {
action_before_close = true,
action_before_exit = false,
save_to_temp_register = false,
}
-- Get the index of the next popup when cycling forward
local function next_index(i, n, count)
count = count > 0 and count or 1

View File

@@ -63,7 +63,7 @@ M.summary = function()
description_popup,
M.edit_summary,
miscellaneous.attach_file,
{ cb = exit, action_before_close = true }
{ cb = exit, action_before_close = true, save_to_temp_register = 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 })

View File

@@ -6,6 +6,7 @@ local M = {}
---@param command table
---@return string|nil, string|nil
local run_system = function(command)
-- Load here to prevent loop
local u = require("gitlab.utils")
local result = vim.fn.trim(vim.fn.system(command))
if vim.v.shell_error ~= 0 then
@@ -16,9 +17,12 @@ local run_system = function(command)
end
---Returns all branches for the current repository
---@param args table|nil extra arguments for `git branch`
---@return string|nil, string|nil
M.branches = function()
return run_system({ "git", "branch" })
M.branches = function(args)
-- Load here to prevent loop
local u = require("gitlab.utils")
return run_system(u.combine({ "git", "branch" }, args or {}))
end
---Checks whether the tree has any changes that haven't been pushed to the remote
@@ -60,7 +64,7 @@ end
---Return the list of names of all remote-tracking branches or an empty list.
---@return table, string|nil
M.get_all_remote_branches = function()
local all_branches, err = M.branches()
local all_branches, err = M.branches({ "--remotes" })
if err ~= nil then
return {}, err
end