mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-29 23:17:32 +02:00
move remotes and remote branches
This commit is contained in:
parent
e849ca3372
commit
eda4619a4f
@ -5,9 +5,11 @@ import (
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/models"
|
||||
)
|
||||
|
||||
func (c *GitCommand) GetRemotes() ([]*Remote, error) {
|
||||
func (c *GitCommand) GetRemotes() ([]*models.Remote, error) {
|
||||
// get remote branches
|
||||
unescaped := "git branch -r"
|
||||
remoteBranchesStr, err := c.OSCommand.RunCommandWithOutput(unescaped)
|
||||
@ -21,21 +23,21 @@ func (c *GitCommand) GetRemotes() ([]*Remote, error) {
|
||||
}
|
||||
|
||||
// first step is to get our remotes from go-git
|
||||
remotes := make([]*Remote, len(goGitRemotes))
|
||||
remotes := make([]*models.Remote, len(goGitRemotes))
|
||||
for i, goGitRemote := range goGitRemotes {
|
||||
remoteName := goGitRemote.Config().Name
|
||||
|
||||
re := regexp.MustCompile(fmt.Sprintf(`%s\/([\S]+)`, remoteName))
|
||||
matches := re.FindAllStringSubmatch(remoteBranchesStr, -1)
|
||||
branches := make([]*RemoteBranch, len(matches))
|
||||
branches := make([]*models.RemoteBranch, len(matches))
|
||||
for j, match := range matches {
|
||||
branches[j] = &RemoteBranch{
|
||||
branches[j] = &models.RemoteBranch{
|
||||
Name: match[1],
|
||||
RemoteName: remoteName,
|
||||
}
|
||||
}
|
||||
|
||||
remotes[i] = &Remote{
|
||||
remotes[i] = &models.Remote{
|
||||
Name: goGitRemote.Config().Name,
|
||||
Urls: goGitRemote.Config().URLs,
|
||||
Branches: branches,
|
||||
|
@ -19,8 +19,8 @@ type CustomCommandObjects struct {
|
||||
SelectedSubCommit *models.Commit
|
||||
SelectedFile *commands.File
|
||||
SelectedLocalBranch *models.Branch
|
||||
SelectedRemoteBranch *commands.RemoteBranch
|
||||
SelectedRemote *commands.Remote
|
||||
SelectedRemoteBranch *models.RemoteBranch
|
||||
SelectedRemote *models.Remote
|
||||
SelectedTag *models.Tag
|
||||
SelectedStashEntry *commands.StashEntry
|
||||
SelectedCommitFile *commands.CommitFile
|
||||
|
@ -286,8 +286,8 @@ type guiState struct {
|
||||
// one and the same
|
||||
ReflogCommits []*models.Commit
|
||||
SubCommits []*models.Commit
|
||||
Remotes []*commands.Remote
|
||||
RemoteBranches []*commands.RemoteBranch
|
||||
Remotes []*models.Remote
|
||||
RemoteBranches []*models.RemoteBranch
|
||||
Tags []*models.Tag
|
||||
MenuItems []*menuItem
|
||||
Updating bool
|
||||
|
@ -1,12 +1,12 @@
|
||||
package presentation
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/models"
|
||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
)
|
||||
|
||||
func GetRemoteBranchListDisplayStrings(branches []*commands.RemoteBranch, diffName string) [][]string {
|
||||
func GetRemoteBranchListDisplayStrings(branches []*models.RemoteBranch, diffName string) [][]string {
|
||||
lines := make([][]string, len(branches))
|
||||
|
||||
for i := range branches {
|
||||
@ -18,7 +18,7 @@ func GetRemoteBranchListDisplayStrings(branches []*commands.RemoteBranch, diffNa
|
||||
}
|
||||
|
||||
// getRemoteBranchDisplayStrings returns the display string of branch
|
||||
func getRemoteBranchDisplayStrings(b *commands.RemoteBranch, diffed bool) []string {
|
||||
func getRemoteBranchDisplayStrings(b *models.RemoteBranch, diffed bool) []string {
|
||||
nameColorAttr := GetBranchColor(b.Name)
|
||||
if diffed {
|
||||
nameColorAttr = theme.DiffTerminalColor
|
||||
|
@ -4,12 +4,12 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/models"
|
||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
)
|
||||
|
||||
func GetRemoteListDisplayStrings(remotes []*commands.Remote, diffName string) [][]string {
|
||||
func GetRemoteListDisplayStrings(remotes []*models.Remote, diffName string) [][]string {
|
||||
lines := make([][]string, len(remotes))
|
||||
|
||||
for i := range remotes {
|
||||
@ -21,7 +21,7 @@ func GetRemoteListDisplayStrings(remotes []*commands.Remote, diffName string) []
|
||||
}
|
||||
|
||||
// getRemoteDisplayStrings returns the display string of branch
|
||||
func getRemoteDisplayStrings(r *commands.Remote, diffed bool) []string {
|
||||
func getRemoteDisplayStrings(r *models.Remote, diffed bool) []string {
|
||||
branchCount := len(r.Branches)
|
||||
|
||||
nameColorAttr := theme.DefaultTextColor
|
||||
|
@ -4,12 +4,12 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/models"
|
||||
)
|
||||
|
||||
// list panel functions
|
||||
|
||||
func (gui *Gui) getSelectedRemoteBranch() *commands.RemoteBranch {
|
||||
func (gui *Gui) getSelectedRemoteBranch() *models.RemoteBranch {
|
||||
selectedLine := gui.State.Panels.RemoteBranches.SelectedLineIdx
|
||||
if selectedLine == -1 || len(gui.State.RemoteBranches) == 0 {
|
||||
return nil
|
||||
|
@ -6,13 +6,13 @@ import (
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/models"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
)
|
||||
|
||||
// list panel functions
|
||||
|
||||
func (gui *Gui) getSelectedRemote() *commands.Remote {
|
||||
func (gui *Gui) getSelectedRemote() *models.Remote {
|
||||
selectedLine := gui.State.Panels.Remotes.SelectedLineIdx
|
||||
if selectedLine == -1 || len(gui.State.Remotes) == 0 {
|
||||
return nil
|
||||
|
@ -1,4 +1,4 @@
|
||||
package commands
|
||||
package models
|
||||
|
||||
// Remote : A git remote
|
||||
type Remote struct {
|
@ -1,4 +1,4 @@
|
||||
package commands
|
||||
package models
|
||||
|
||||
// Remote Branch : A git remote branch
|
||||
type RemoteBranch struct {
|
Loading…
x
Reference in New Issue
Block a user