File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,14 @@ function M.to_elsewhere(popup)
111111 end
112112end
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+
114122function 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 )
134144end
135145
You can’t perform that action at this time.
0 commit comments