diff --git a/command/testing.go b/command/testing.go index 7fe86c255..0668776c8 100644 --- a/command/testing.go +++ b/command/testing.go @@ -29,11 +29,6 @@ const defaultTestConfig = `hosts: func initBlankContext(cfg, repo, branch string) { initContext = func() context.Context { ctx := context.NewBlank() - ctx.SetBaseRepo(repo) - ctx.SetBranch(branch) - ctx.SetRemotes(map[string]string{ - "origin": "OWNER/REPO", - }) if cfg == "" { cfg = defaultTestConfig diff --git a/context/blank_context.go b/context/blank_context.go index f14310937..96f599981 100644 --- a/context/blank_context.go +++ b/context/blank_context.go @@ -2,11 +2,8 @@ package context import ( "fmt" - "strings" - "github.com/cli/cli/git" "github.com/cli/cli/internal/config" - "github.com/cli/cli/internal/ghrepo" ) // NewBlank initializes a blank Context suitable for testing @@ -16,9 +13,6 @@ func NewBlank() *blankContext { // A Context implementation that queries the filesystem type blankContext struct { - branch string - baseRepo ghrepo.Interface - remotes Remotes } func (c *blankContext) Config() (config.Config, error) { @@ -28,51 +22,3 @@ func (c *blankContext) Config() (config.Config, error) { } return cfg, nil } - -func (c *blankContext) Branch() (string, error) { - if c.branch == "" { - return "", fmt.Errorf("branch was not initialized: %w", git.ErrNotOnAnyBranch) - } - return c.branch, nil -} - -func (c *blankContext) SetBranch(b string) { - c.branch = b -} - -func (c *blankContext) Remotes() (Remotes, error) { - if c.remotes == nil { - return nil, fmt.Errorf("remotes were not initialized") - } - return c.remotes, nil -} - -func (c *blankContext) SetRemotes(stubs map[string]string) { - c.remotes = make([]*Remote, 0, len(stubs)) - for remoteName, repo := range stubs { - ownerWithName := strings.SplitN(repo, "/", 2) - c.remotes = append(c.remotes, &Remote{ - Remote: &git.Remote{Name: remoteName}, - Repo: ghrepo.New(ownerWithName[0], ownerWithName[1]), - }) - } -} - -func (c *blankContext) BaseRepo() (ghrepo.Interface, error) { - if c.baseRepo != nil { - return c.baseRepo, nil - } - remotes, err := c.Remotes() - if err != nil { - return nil, err - } - if len(remotes) < 1 { - return nil, fmt.Errorf("remotes are empty") - } - return remotes[0], nil -} - -func (c *blankContext) SetBaseRepo(nwo string) { - repo, _ := ghrepo.FromFullName(nwo) - c.baseRepo = repo -} diff --git a/context/context.go b/context/context.go index 06a89067d..e2600b02e 100644 --- a/context/context.go +++ b/context/context.go @@ -8,7 +8,6 @@ import ( "strings" "github.com/cli/cli/api" - "github.com/cli/cli/git" "github.com/cli/cli/internal/config" "github.com/cli/cli/internal/ghrepo" ) @@ -154,9 +153,7 @@ func New() Context { // A Context implementation that queries the filesystem type fsContext struct { - config config.Config - branch string - baseRepo ghrepo.Interface + config config.Config } func (c *fsContext) Config() (config.Config, error) { @@ -171,25 +168,3 @@ func (c *fsContext) Config() (config.Config, error) { } return c.config, nil } - -func (c *fsContext) Branch() (string, error) { - if c.branch != "" { - return c.branch, nil - } - - currentBranch, err := git.CurrentBranch() - if err != nil { - return "", fmt.Errorf("could not determine current branch: %w", err) - } - - c.branch = currentBranch - return c.branch, nil -} - -func (c *fsContext) SetBranch(b string) { - c.branch = b -} - -func (c *fsContext) SetBaseRepo(nwo string) { - c.baseRepo, _ = ghrepo.FromFullName(nwo) -}