8000 fix: error when --remote flag used with repo argument by majiayu000 · Pull Request #12375 · cli/cli · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/cmd/repo/fork/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ func NewCmdFork(f *cmdutil.Factory, runF func(*ForkOptions) error) *cobra.Comman
opts.Rename = true // Any existing 'origin' will be renamed to upstream
}

if opts.Repository != "" && cmd.Flags().Changed("remote") {
return cmdutil.FlagErrorf("the `--remote` flag is unsupported when a repository argument is provided")
}

if promptOk {
// We can prompt for these if they were not specified.
opts.PromptClone = !cmd.Flags().Changed("clone")
Expand Down
6 changes: 6 additions & 0 deletions pkg/cmd/repo/fork/fork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ func TestNewCmdFork(t *testing.T) {
Rename: false,
},
},
{
name: "remote with repo argument",
cli: "foo/bar --remote",
wantErr: true,
errMsg: "the `--remote` flag is unsupported when a repository argument is provided",
},
}

for _, tt := range tests {
Expand Down
0