diff options
Diffstat (limited to 'pkg/gui/remote_branches_panel.go')
-rw-r--r-- | pkg/gui/remote_branches_panel.go | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/pkg/gui/remote_branches_panel.go b/pkg/gui/remote_branches_panel.go index 0c00f8d80..243a7ca4d 100644 --- a/pkg/gui/remote_branches_panel.go +++ b/pkg/gui/remote_branches_panel.go @@ -4,25 +4,15 @@ import ( "fmt" "strings" - "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" ) // list panel functions -func (gui *Gui) getSelectedRemoteBranch() *models.RemoteBranch { - selectedLine := gui.State.Panels.RemoteBranches.SelectedLineIdx - if selectedLine == -1 || len(gui.State.Model.RemoteBranches) == 0 { - return nil - } - - return gui.State.Model.RemoteBranches[selectedLine] -} - func (gui *Gui) remoteBranchesRenderToMain() error { var task updateTask - remoteBranch := gui.getSelectedRemoteBranch() + remoteBranch := gui.State.Contexts.RemoteBranches.GetSelected() if remoteBranch == nil { task = NewRenderStringTask("No branches for this remote") } else { @@ -43,12 +33,12 @@ func (gui *Gui) handleRemoteBranchesEscape() error { } func (gui *Gui) handleMergeRemoteBranch() error { - selectedBranchName := gui.getSelectedRemoteBranch().FullName() + selectedBranchName := gui.State.Contexts.RemoteBranches.GetSelected().FullName() return gui.mergeBranchIntoCheckedOutBranch(selectedBranchName) } func (gui *Gui) handleDeleteRemoteBranch() error { - remoteBranch := gui.getSelectedRemoteBranch() + remoteBranch := gui.State.Contexts.RemoteBranches.GetSelected() if remoteBranch == nil { return nil } @@ -72,12 +62,12 @@ func (gui *Gui) handleDeleteRemoteBranch() error { } func (gui *Gui) handleRebaseOntoRemoteBranch() error { - selectedBranchName := gui.getSelectedRemoteBranch().FullName() + selectedBranchName := gui.State.Contexts.RemoteBranches.GetSelected().FullName() return gui.handleRebaseOntoBranch(selectedBranchName) } func (gui *Gui) handleSetBranchUpstream() error { - selectedBranch := gui.getSelectedRemoteBranch() + selectedBranch := gui.State.Contexts.RemoteBranches.GetSelected() checkedOutBranch := gui.getCheckedOutBranch() message := utils.ResolvePlaceholderString( @@ -103,7 +93,7 @@ func (gui *Gui) handleSetBranchUpstream() error { } func (gui *Gui) handleCreateResetToRemoteBranchMenu() error { - selectedBranch := gui.getSelectedRemoteBranch() + selectedBranch := gui.State.Contexts.RemoteBranches.GetSelected() if selectedBranch == nil { return nil } @@ -112,7 +102,7 @@ func (gui *Gui) handleCreateResetToRemoteBranchMenu() error { } func (gui *Gui) handleEnterRemoteBranch() error { - selectedBranch := gui.getSelectedRemoteBranch() + selectedBranch := gui.State.Contexts.RemoteBranches.GetSelected() if selectedBranch == nil { return nil } @@ -121,7 +111,7 @@ func (gui *Gui) handleEnterRemoteBranch() error { } func (gui *Gui) handleNewBranchOffRemoteBranch() error { - selectedBranch := gui.getSelectedRemoteBranch() + selectedBranch := gui.State.Contexts.RemoteBranches.GetSelected() if selectedBranch == nil { return nil } |