Skip to content

Commit 1d506f5

Browse files
committed
fix: simplify set-default remote parsing
1 parent 8de78e6 commit 1d506f5

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

pkg/cmd/repo/setdefault/setdefault.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ func NewCmdSetDefault(f *cmdutil.Factory, runF func(*SetDefaultOptions) error) *
9292
var err error
9393
opts.Repo, err = ghrepo.FromFullName(args[0])
9494
if err != nil {
95-
if opts.Remotes == nil {
96-
return fmt.Errorf("given arg is not a valid repo or git remote: %w", err)
97-
}
98-
9995
remotes, remoteErr := opts.Remotes()
10096
if remoteErr != nil {
10197
return remoteErr

pkg/cmd/repo/setdefault/setdefault_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,17 @@ func TestNewCmdSetDefault(t *testing.T) {
116116
io.SetStdoutTTY(true)
117117
io.SetStdinTTY(true)
118118
io.SetStderrTTY(true)
119+
remotesFunc := tt.remotes
120+
if remotesFunc == nil {
121+
remotesFunc = func() (context.Remotes, error) {
122+
return context.Remotes{}, nil
123+
}
124+
}
125+
119126
f := &cmdutil.Factory{
120127
IOStreams: io,
121128
GitClient: &git.Client{GitPath: "/fake/path/to/git"},
122-
Remotes: tt.remotes,
129+
Remotes: remotesFunc,
123130
}
124131

125132
var gotOpts *SetDefaultOptions

0 commit comments

Comments
 (0)