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.
This commit is contained in:
camille folch 2021-06-08 20:22:57 -03:00
parent aecfc01e69
commit 54b86c7093
No known key found for this signature in database
GPG key ID: F67AC3874B6D8FF1
2 changed files with 10 additions and 0 deletions

View file

@ -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")}
}

View file

@ -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",