@@ -2,11 +2,8 @@ package context
22
33import (
44 "fmt"
5- "strings"
65
7- "github.com/cli/cli/git"
86 "github.com/cli/cli/internal/config"
9- "github.com/cli/cli/internal/ghrepo"
107)
118
129// NewBlank initializes a blank Context suitable for testing
@@ -16,9 +13,6 @@ func NewBlank() *blankContext {
1613
1714// A Context implementation that queries the filesystem
1815type blankContext struct {
19- branch string
20- baseRepo ghrepo.Interface
21- remotes Remotes
2216}
2317
2418func (c * blankContext ) Config () (config.Config , error ) {
@@ -28,51 +22,3 @@ func (c *blankContext) Config() (config.Config, error) {
2822 }
2923 return cfg , nil
3024}
31-
32- func (c * blankContext ) Branch () (string , error ) {
33- if c .branch == "" {
34- return "" , fmt .Errorf ("branch was not initialized: %w" , git .ErrNotOnAnyBranch )
35- }
36- return c .branch , nil
37- }
38-
39- func (c * blankContext ) SetBranch (b string ) {
40- c .branch = b
41- }
42-
43- func (c * blankContext ) Remotes () (Remotes , error ) {
44- if c .remotes == nil {
45- return nil , fmt .Errorf ("remotes were not initialized" )
46- }
47- return c .remotes , nil
48- }
49-
50- func (c * blankContext ) SetRemotes (stubs map [string ]string ) {
51- c .remotes = make ([]* Remote , 0 , len (stubs ))
52- for remoteName , repo := range stubs {
53- ownerWithName := strings .SplitN (repo , "/" , 2 )
54- c .remotes = append (c .remotes , & Remote {
55- Remote : & git.Remote {Name : remoteName },
56- Repo : ghrepo .New (ownerWithName [0 ], ownerWithName [1 ]),
57- })
58- }
59- }
60-
61- func (c * blankContext ) BaseRepo () (ghrepo.Interface , error ) {
62- if c .baseRepo != nil {
63- return c .baseRepo , nil
64- }
65- remotes , err := c .Remotes ()
66- if err != nil {
67- return nil , err
68- }
69- if len (remotes ) < 1 {
70- return nil , fmt .Errorf ("remotes are empty" )
71- }
72- return remotes [0 ], nil
73- }
74-
75- func (c * blankContext ) SetBaseRepo (nwo string ) {
76- repo , _ := ghrepo .FromFullName (nwo )
77- c .baseRepo = repo
78- }
0 commit comments