fix: simplify set-default remote parsing
This commit is contained in:
parent
8de78e6410
commit
1d506f5331
2 changed files with 8 additions and 5 deletions
|
|
@ -92,10 +92,6 @@ func NewCmdSetDefault(f *cmdutil.Factory, runF func(*SetDefaultOptions) error) *
|
|||
var err error
|
||||
opts.Repo, err = ghrepo.FromFullName(args[0])
|
||||
if err != nil {
|
||||
if opts.Remotes == nil {
|
||||
return fmt.Errorf("given arg is not a valid repo or git remote: %w", err)
|
||||
}
|
||||
|
||||
remotes, remoteErr := opts.Remotes()
|
||||
if remoteErr != nil {
|
||||
return remoteErr
|
||||
|
|
|
|||
|
|
@ -116,10 +116,17 @@ func TestNewCmdSetDefault(t *testing.T) {
|
|||
io.SetStdoutTTY(true)
|
||||
io.SetStdinTTY(true)
|
||||
io.SetStderrTTY(true)
|
||||
remotesFunc := tt.remotes
|
||||
if remotesFunc == nil {
|
||||
remotesFunc = func() (context.Remotes, error) {
|
||||
return context.Remotes{}, nil
|
||||
}
|
||||
}
|
||||
|
||||
f := &cmdutil.Factory{
|
||||
IOStreams: io,
|
||||
GitClient: &git.Client{GitPath: "/fake/path/to/git"},
|
||||
Remotes: tt.remotes,
|
||||
Remotes: remotesFunc,
|
||||
}
|
||||
|
||||
var gotOpts *SetDefaultOptions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue