summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-11-13 23:18:29 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-11-21 22:07:14 +1100
commit092f27495a6b362537d2f8b7ff95bf29ee21f285 (patch)
treedfcf633b473ed8218ce6ae0974c40a2d43124995 /pkg/commands
parent7849f91d80a83b61a141d2a38b035f1cf934c4c1 (diff)
add remote model
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/git.go17
-rw-r--r--pkg/commands/remote.go14
2 files changed, 31 insertions, 0 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index ad275d10f..40e4bccf7 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -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
+}
diff --git a/pkg/commands/remote.go b/pkg/commands/remote.go
new file mode 100644
index 000000000..7e9e5f6f8
--- /dev/null
+++ b/pkg/commands/remote.go
@@ -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}
+}