Skip to content

Commit

Permalink
Ensure current branch is not in list of options for merging
Browse files Browse the repository at this point in the history
  • Loading branch information
CKolkey committed Dec 14, 2024
1 parent ab6966d commit cfea08e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions lua/neogit/popups/merge/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@ function M.abort()
end
end

function M.merge(popup)
---@param popup PopupData
---@return string[]
local function get_refs(popup)
local refs = util.merge({ popup.state.env.commit }, git.refs.list_branches(), git.refs.list_tags())
util.remove_item_from_table(refs, git.branch.current())

return refs
end

local ref = FuzzyFinderBuffer.new(refs):open_async { prompt_prefix = "Merge" }
function M.merge(popup)
local ref = FuzzyFinderBuffer.new(get_refs(popup)):open_async { prompt_prefix = "Merge" }
if ref then
local args = popup:get_arguments()
table.insert(args, "--no-edit")
Expand All @@ -28,9 +35,7 @@ function M.merge(popup)
end

function M.squash(popup)
local refs = util.merge({ popup.state.env.commit }, git.refs.list_branches(), git.refs.list_tags())

local ref = FuzzyFinderBuffer.new(refs):open_async { prompt_prefix = "Squash" }
local ref = FuzzyFinderBuffer.new(get_refs(popup)):open_async { prompt_prefix = "Squash" }
if ref then
local args = popup:get_arguments()
table.insert(args, "--squash")
Expand All @@ -39,9 +44,7 @@ function M.squash(popup)
end

function M.merge_edit(popup)
local refs = util.merge({ popup.state.env.commit }, git.refs.list_branches(), git.refs.list_tags())

local ref = FuzzyFinderBuffer.new(refs):open_async { prompt_prefix = "Merge" }
local ref = FuzzyFinderBuffer.new(get_refs(popup)):open_async { prompt_prefix = "Merge" }
if ref then
local args = popup:get_arguments()
table.insert(args, "--edit")
Expand All @@ -55,9 +58,7 @@ function M.merge_edit(popup)
end

function M.merge_nocommit(popup)
local refs = util.merge({ popup.state.env.commit }, git.refs.list_branches(), git.refs.list_tags())

local ref = FuzzyFinderBuffer.new(refs):open_async { prompt_prefix = "Merge" }
local ref = FuzzyFinderBuffer.new(get_refs(popup)):open_async { prompt_prefix = "Merge" }
if ref then
local args = popup:get_arguments()
table.insert(args, "--no-commit")
Expand Down

0 comments on commit cfea08e

Please sign in to comment.