mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-10 04:07:18 +02:00
allow creating branches off of remote branches
This commit is contained in:
parent
04e93317b8
commit
003e45d2f5
@ -1287,6 +1287,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||||||
Handler: gui.handleCheckoutRemoteBranch,
|
Handler: gui.handleCheckoutRemoteBranch,
|
||||||
Description: gui.Tr.SLocalize("checkout"),
|
Description: gui.Tr.SLocalize("checkout"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ViewName: "branches",
|
||||||
|
Contexts: []string{"remote-branches"},
|
||||||
|
Key: gui.getKey("universal.new"),
|
||||||
|
Handler: gui.handleNewBranchOffRemote,
|
||||||
|
Description: gui.Tr.SLocalize("newBranch"),
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
ViewName: "branches",
|
ViewName: "branches",
|
||||||
Contexts: []string{"remote-branches"},
|
Contexts: []string{"remote-branches"},
|
||||||
|
@ -139,3 +139,26 @@ func (gui *Gui) handleCreateResetToRemoteBranchMenu(g *gocui.Gui, v *gocui.View)
|
|||||||
|
|
||||||
return gui.createResetMenu(fmt.Sprintf("%s/%s", selectedBranch.RemoteName, selectedBranch.Name))
|
return gui.createResetMenu(fmt.Sprintf("%s/%s", selectedBranch.RemoteName, selectedBranch.Name))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) handleNewBranchOffRemote(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
branch := gui.getSelectedRemoteBranch()
|
||||||
|
if branch == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
message := gui.Tr.TemplateLocalize(
|
||||||
|
"NewBranchNameBranchOff",
|
||||||
|
Teml{
|
||||||
|
"branchName": branch.FullName(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return gui.createPromptPanel(g, v, message, branch.FullName(), func(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
if err := gui.GitCommand.NewBranch(gui.trimmedContent(v), branch.FullName()); err != nil {
|
||||||
|
return gui.surfaceError(err)
|
||||||
|
}
|
||||||
|
gui.State.Panels.Branches.SelectedLine = 0
|
||||||
|
if err := gui.switchBranchesPanelContext("local-branches"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return gui.refreshSidePanels(refreshOptions{mode: ASYNC})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user