Skip to content

Commit 54b86c7

Browse files
committed
repo fork: check that --org is not the empty string
As it is already being done for --remote-name, except in this case the default is the empty string.
1 parent aecfc01 commit 54b86c7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pkg/cmd/repo/fork/fork.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ Additional 'git clone' flags can be passed in by listing them after '--'.`,
8383
opts.GitArgs = args[1:]
8484
}
8585

86+
if cmd.Flags().Changed("org") && opts.Organization == "" {
87+
return &cmdutil.FlagError{Err: errors.New("--org cannot be blank")}
88+
}
89+
8690
if opts.RemoteName == "" {
8791
return &cmdutil.FlagError{Err: errors.New("--remote-name cannot be blank")}
8892
}

pkg/cmd/repo/fork/fork_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ func TestNewCmdFork(t *testing.T) {
120120
Organization: "batmanshome",
121121
},
122122
},
123+
{
124+
name: "empty org",
125+
cli: " --org=''",
126+
wantErr: true,
127+
errMsg: "--org cannot be blank",
128+
},
123129
{
124130
name: "git flags in wrong place",
125131
cli: "--depth 1 OWNER/REPO",

0 commit comments

Comments
 (0)