From 54b86c70937f4cf9b75877fa31127a2cf9c796a3 Mon Sep 17 00:00:00 2001 From: camille folch Date: Tue, 8 Jun 2021 20:22:57 -0300 Subject: [PATCH] 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. --- pkg/cmd/repo/fork/fork.go | 4 ++++ pkg/cmd/repo/fork/fork_test.go | 6 ++++++ 2 files changed, 10 insertions(+) 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",