mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-08 23:56:15 +02:00
add remotes context to branches view
This commit is contained in:
parent
092f27495a
commit
e6be849eb2
@ -84,6 +84,10 @@ func (gui *Gui) RenderSelectedBranchUpstreamDifferences() error {
|
|||||||
// gui.refreshStatus is called at the end of this because that's when we can
|
// gui.refreshStatus is called at the end of this because that's when we can
|
||||||
// be sure there is a state.Branches array to pick the current branch from
|
// be sure there is a state.Branches array to pick the current branch from
|
||||||
func (gui *Gui) refreshBranches(g *gocui.Gui) error {
|
func (gui *Gui) refreshBranches(g *gocui.Gui) error {
|
||||||
|
if err := gui.refreshRemotes(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
g.Update(func(g *gocui.Gui) error {
|
g.Update(func(g *gocui.Gui) error {
|
||||||
builder, err := commands.NewBranchListBuilder(gui.Log, gui.GitCommand)
|
builder, err := commands.NewBranchListBuilder(gui.Log, gui.GitCommand)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -358,3 +362,40 @@ func (gui *Gui) handleFastForward(g *gocui.Gui, v *gocui.View) error {
|
|||||||
}()
|
}()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) onBranchesTabClick(tabIndex int) error {
|
||||||
|
gui.State.Panels.Branches.ContextIndex = tabIndex
|
||||||
|
branchesView := gui.getBranchesView()
|
||||||
|
branchesView.TabIndex = tabIndex
|
||||||
|
|
||||||
|
switch tabIndex {
|
||||||
|
case 0:
|
||||||
|
if err := gui.renderListPanel(branchesView, gui.State.Branches); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
if err := gui.renderListPanel(branchesView, gui.State.Remotes); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// gui.refreshStatus is called at the end of this because that's when we can
|
||||||
|
// be sure there is a state.Branches array to pick the current branch from
|
||||||
|
func (gui *Gui) refreshRemotes() error {
|
||||||
|
remotes, err := gui.GitCommand.GetRemotes()
|
||||||
|
if err != nil {
|
||||||
|
return gui.createErrorPanel(gui.g, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
gui.State.Remotes = remotes
|
||||||
|
|
||||||
|
gui.g.Update(func(g *gocui.Gui) error {
|
||||||
|
gui.refreshSelectedLine(&gui.State.Panels.Remotes.SelectedLine, len(gui.State.Remotes))
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -107,8 +107,14 @@ type filePanelState struct {
|
|||||||
SelectedLine int
|
SelectedLine int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: consider splitting this out into the window and the branches view
|
||||||
type branchPanelState struct {
|
type branchPanelState struct {
|
||||||
SelectedLine int
|
SelectedLine int
|
||||||
|
ContextIndex int
|
||||||
|
}
|
||||||
|
|
||||||
|
type remotePanelState struct {
|
||||||
|
SelectedLine int
|
||||||
}
|
}
|
||||||
|
|
||||||
type commitPanelState struct {
|
type commitPanelState struct {
|
||||||
@ -137,6 +143,7 @@ type statusPanelState struct {
|
|||||||
type panelStates struct {
|
type panelStates struct {
|
||||||
Files *filePanelState
|
Files *filePanelState
|
||||||
Branches *branchPanelState
|
Branches *branchPanelState
|
||||||
|
Remotes *remotePanelState
|
||||||
Commits *commitPanelState
|
Commits *commitPanelState
|
||||||
Stash *stashPanelState
|
Stash *stashPanelState
|
||||||
Menu *menuPanelState
|
Menu *menuPanelState
|
||||||
@ -153,6 +160,7 @@ type guiState struct {
|
|||||||
StashEntries []*commands.StashEntry
|
StashEntries []*commands.StashEntry
|
||||||
CommitFiles []*commands.CommitFile
|
CommitFiles []*commands.CommitFile
|
||||||
DiffEntries []*commands.Commit
|
DiffEntries []*commands.Commit
|
||||||
|
Remotes []*commands.Remote
|
||||||
MenuItemCount int // can't store the actual list because it's of interface{} type
|
MenuItemCount int // can't store the actual list because it's of interface{} type
|
||||||
PreviousView string
|
PreviousView string
|
||||||
Platform commands.Platform
|
Platform commands.Platform
|
||||||
@ -183,6 +191,7 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *comma
|
|||||||
Panels: &panelStates{
|
Panels: &panelStates{
|
||||||
Files: &filePanelState{SelectedLine: -1},
|
Files: &filePanelState{SelectedLine: -1},
|
||||||
Branches: &branchPanelState{SelectedLine: 0},
|
Branches: &branchPanelState{SelectedLine: 0},
|
||||||
|
Remotes: &remotePanelState{SelectedLine: -1},
|
||||||
Commits: &commitPanelState{SelectedLine: -1},
|
Commits: &commitPanelState{SelectedLine: -1},
|
||||||
CommitFiles: &commitFilesPanelState{SelectedLine: -1},
|
CommitFiles: &commitFilesPanelState{SelectedLine: -1},
|
||||||
Stash: &stashPanelState{SelectedLine: -1},
|
Stash: &stashPanelState{SelectedLine: -1},
|
||||||
@ -480,6 +489,8 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
branchesView.Title = gui.Tr.SLocalize("BranchesTitle")
|
branchesView.Title = gui.Tr.SLocalize("BranchesTitle")
|
||||||
|
branchesView.Tabs = []string{"Local Branches", "Remotes"}
|
||||||
|
branchesView.TabIndex = gui.State.Panels.Branches.ContextIndex
|
||||||
branchesView.FgColor = textColor
|
branchesView.FgColor = textColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,6 +631,11 @@ func (gui *Gui) keybindings(g *gocui.Gui) error {
|
|||||||
if err := gui.setInitialContext(); err != nil {
|
if err := gui.setInitialContext(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := g.SetTabClickBinding("branches", gui.onBranchesTabClick); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user