trying to use gogit with branches from remotes

This commit is contained in:
Jesse Duffield
2019-11-21 21:15:05 +11:00
parent fdb2880075
commit 3ea79ef4e1
2 changed files with 23 additions and 2 deletions
+22 -2
View File
@@ -1068,12 +1068,32 @@ func (c *GitCommand) GetRemotes() ([]*Remote, error) {
return nil, err
}
return nil, nil
remotes := make([]*Remote, len(goGitRemotes))
// TODO: consider including the goGitRemote itself
for i, goGitRemote := range goGitRemotes {
goGitBranches, err := goGitRemote.List(&gogit.ListOptions{})
if err != nil {
c.Log.Warn(err)
continue
}
branches := []*Branch{}
for _, goGitBranch := range goGitBranches {
// for now we're only getting branch references, not tags/notes/etc
if goGitBranch.Name().IsBranch() {
branches = append(branches, &Branch{
Name: goGitBranch.Name().String(),
})
}
}
remotes[i] = &Remote{
Name: goGitRemote.Config().Name,
Urls: goGitRemote.Config().URLs,
Name: goGitRemote.Config().Name,
Urls: goGitRemote.Config().URLs,
Branches: branches,
}
}
return remotes, nil
+1
View File
@@ -5,6 +5,7 @@ type Remote struct {
Name string
Urls []string
Selected bool
Branches []*Branch
}
// GetDisplayStrings returns the display string of a remote