mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-09 07:24:03 +02:00
move into more appropriate file
This commit is contained in:
parent
8da93fd762
commit
134566ed49
@ -468,3 +468,40 @@ func (gui *Gui) handleClipboardCopyBranch(g *gocui.Gui, v *gocui.View) error {
|
||||
|
||||
return gui.OSCommand.CopyToClipboard(branch.Name)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleNewBranchOffCurrentItem() error {
|
||||
context := gui.currentSideContext()
|
||||
|
||||
item := context.GetSelectedItem()
|
||||
if item == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
message := gui.Tr.TemplateLocalize(
|
||||
"NewBranchNameBranchOff",
|
||||
Teml{
|
||||
"branchName": item.Description(),
|
||||
},
|
||||
)
|
||||
|
||||
return gui.prompt(gui.getCurrentSideView(), message, "", func(response string) error {
|
||||
if err := gui.GitCommand.NewBranch(response, item.ID()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// if we're currently in the branch commits context then the selected commit
|
||||
// is about to go to the top of the list
|
||||
if context.GetKey() == BRANCH_COMMITS_CONTEXT_KEY {
|
||||
context.GetPanelState().SetSelectedLineIdx(0)
|
||||
}
|
||||
|
||||
if context.GetKey() != gui.Contexts.Branches.Context.GetKey() {
|
||||
if err := gui.switchContext(gui.Contexts.Branches.Context); err != nil {
|
||||
return err
|
||||
}
|
||||
gui.State.Panels.Branches.SelectedLineIdx = 0
|
||||
}
|
||||
|
||||
return gui.refreshSidePanels(refreshOptions{mode: ASYNC})
|
||||
})
|
||||
}
|
||||
|
@ -674,37 +674,3 @@ func (gui *Gui) handleClipboardCopyCommit(g *gocui.Gui, v *gocui.View) error {
|
||||
|
||||
return gui.OSCommand.CopyToClipboard(commit.Sha)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleNewBranchOffCurrentItem() error {
|
||||
context := gui.currentSideContext()
|
||||
|
||||
itemId := context.GetSelectedItemId()
|
||||
|
||||
message := gui.Tr.TemplateLocalize(
|
||||
"NewBranchNameBranchOff",
|
||||
Teml{
|
||||
"branchName": itemId, // TODO: add 'long name' field on ListItem interface (right now we just get an ugly commit SHA for commits)
|
||||
},
|
||||
)
|
||||
|
||||
return gui.prompt(gui.getCurrentSideView(), message, "", func(response string) error {
|
||||
if err := gui.GitCommand.NewBranch(response, itemId); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// if we're currently in the branch commits context then the selected commit
|
||||
// is about to go to the top of the list
|
||||
if context.GetKey() == BRANCH_COMMITS_CONTEXT_KEY {
|
||||
context.GetPanelState().SetSelectedLineIdx(0)
|
||||
}
|
||||
|
||||
if context.GetKey() != gui.Contexts.Branches.Context.GetKey() {
|
||||
if err := gui.switchContext(gui.Contexts.Branches.Context); err != nil {
|
||||
return err
|
||||
}
|
||||
gui.State.Panels.Branches.SelectedLineIdx = 0
|
||||
}
|
||||
|
||||
return gui.refreshSidePanels(refreshOptions{mode: ASYNC})
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user