Skip to content

Commit c43a142

Browse files
gn-dave-aactionshrimp
authored andcommitted
fix push other workflow
1 parent 49d0527 commit c43a142

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lua/neogit/popups/push/actions.lua

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ function M.to_elsewhere(popup)
111111
end
112112
end
113113

114+
local function remove_prefix(str, prefix)
115+
if str:sub(1, #prefix) == prefix then
116+
return str:sub(#prefix + 1)
117+
else
118+
return str
119+
end
120+
end
121+
114122
function M.push_other(popup)
115123
local sources = util.merge({ popup.state.env.commit }, git.refs.list_local_branches(), git.refs.heads())
116124
local source = FuzzyFinderBuffer.new(sources):open_async { prompt_prefix = "push" }
@@ -119,17 +127,19 @@ function M.push_other(popup)
119127
end
120128

121129
local destinations = git.refs.list_remote_branches()
122-
for _, remote in ipairs(git.remote.list()) do
123-
table.insert(destinations, 1, remote .. "/" .. source)
124-
end
125130

126131
local destination = FuzzyFinderBuffer.new(util.deduplicate(destinations))
127132
:open_async { prompt_prefix = "push " .. source .. " to" }
133+
128134
if not destination then
129135
return
130136
end
131137

132138
local remote, _ = git.branch.parse_remote_branch(destination)
139+
--
140+
-- destination is <remote>/branch-name, need to remove the remote prefix
141+
destination = remove_prefix(destination, remote .. "/")
142+
133143
push_to(popup:get_arguments(), remote, source .. ":" .. destination)
134144
end
135145

0 commit comments

Comments
 (0)