1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/gui/remotes_panel.go
2022-03-17 19:13:40 +11:00

38 lines
826 B
Go

package gui
import (
"fmt"
"strings"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/style"
)
// list panel functions
func (gui *Gui) getSelectedRemote() *models.Remote {
selectedLine := gui.State.Panels.Remotes.SelectedLineIdx
if selectedLine == -1 || len(gui.State.Remotes) == 0 {
return nil
}
return gui.State.Remotes[selectedLine]
}
func (gui *Gui) remotesRenderToMain() error {
var task updateTask
remote := gui.getSelectedRemote()
if remote == nil {
task = NewRenderStringTask("No remotes")
} else {
task = NewRenderStringTask(fmt.Sprintf("%s\nUrls:\n%s", style.FgGreen.Sprint(remote.Name), strings.Join(remote.Urls, "\n")))
}
return gui.refreshMainViews(refreshMainOpts{
main: &viewUpdateOpts{
title: "Remote",
task: task,
},
})
}