diff --git a/pkg/cmd/repo/fork/fork.go b/pkg/cmd/repo/fork/fork.go index a441b1af5..36deda843 100644 --- a/pkg/cmd/repo/fork/fork.go +++ b/pkg/cmd/repo/fork/fork.go @@ -83,6 +83,10 @@ Additional 'git clone' flags can be passed in by listing them after '--'.`, opts.GitArgs = args[1:] } + if cmd.Flags().Changed("org") && opts.Organization == "" { + return &cmdutil.FlagError{Err: errors.New("--org cannot be blank")} + } + if opts.RemoteName == "" { return &cmdutil.FlagError{Err: errors.New("--remote-name cannot be blank")} } diff --git a/pkg/cmd/repo/fork/fork_test.go b/pkg/cmd/repo/fork/fork_test.go index 914f60af8..1eb42943d 100644 --- a/pkg/cmd/repo/fork/fork_test.go +++ b/pkg/cmd/repo/fork/fork_test.go @@ -120,6 +120,12 @@ func TestNewCmdFork(t *testing.T) { Organization: "batmanshome", }, }, + { + name: "empty org", + cli: " --org=''", + wantErr: true, + errMsg: "--org cannot be blank", + }, { name: "git flags in wrong place", cli: "--depth 1 OWNER/REPO",