Skip to content

Commit

Permalink
When the user selects a remote branch as the base for a new branch,
Browse files Browse the repository at this point in the history
autopopulate the input with the remote's branch name

Fixes: #1497
  • Loading branch information
CKolkey committed Oct 4, 2024
1 parent d7cb075 commit 981bf51
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lua/neogit/popups/branch/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,20 @@ local function create_branch(popup, prompt, checkout, name)
return
end

-- If the base branch is a remote, prepopulate the branch name
local suggested_branch_name
for _, remote in ipairs(git.remote.list()) do
local pattern = ("^%s/(.*)"):format(remote)
if base_branch:match(pattern) then
suggested_branch_name = base_branch:match(pattern)
break
end
end

local name = name
or input.get_user_input("Create branch", {
strip_spaces = true,
default = popup.state.env.suggested_branch_name,
default = popup.state.env.suggested_branch_name or suggested_branch_name,
})
if not name then
return
Expand Down

1 comment on commit 981bf51

@bagnaram
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for doing this!

Please sign in to comment.