1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-11-26 09:00:57 +02:00

add remote model

This commit is contained in:
Jesse Duffield 2019-11-13 23:18:29 +11:00
parent 7849f91d80
commit 092f27495a
2 changed files with 31 additions and 0 deletions

View File

@ -1061,3 +1061,20 @@ func (c *GitCommand) BeginInteractiveRebaseForCommit(commits []*Commit, commitIn
func (c *GitCommand) SetUpstreamBranch(upstream string) error {
return c.OSCommand.RunCommand(fmt.Sprintf("git branch -u %s", upstream))
}
func (c *GitCommand) GetRemotes() ([]*Remote, error) {
goGitRemotes, err := c.Repo.Remotes()
if err != nil {
return nil, err
}
remotes := make([]*Remote, len(goGitRemotes))
// TODO: consider including the goGitRemote itself
for i, goGitRemote := range goGitRemotes {
remotes[i] = &Remote{
Name: goGitRemote.Config().Name,
Urls: goGitRemote.Config().URLs,
}
}
return remotes, nil
}

14
pkg/commands/remote.go Normal file
View File

@ -0,0 +1,14 @@
package commands
// Remote : A git remote
type Remote struct {
Name string
Urls []string
Selected bool
}
// GetDisplayStrings returns the display string of a remote
func (r *Remote) GetDisplayStrings(isFocused bool) []string {
return []string{r.Name}
}