Skip to content

Commit 628dea6

Browse files
authored
Merge pull request cli#12375 from majiayu000/2722-fix-fork-remote-flag
fix: error when --remote flag used with repo argument
2 parents 0f5355e + 1c36686 commit 628dea6

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

pkg/cmd/repo/fork/fork.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ func NewCmdFork(f *cmdutil.Factory, runF func(*ForkOptions) error) *cobra.Comman
113113
opts.Rename = true // Any existing 'origin' will be renamed to upstream
114114
}
115115

116+
if opts.Repository != "" && cmd.Flags().Changed("remote") {
117+
return cmdutil.FlagErrorf("the `--remote` flag is unsupported when a repository argument is provided")
118+
}
119+
116120
if promptOk {
117121
// We can prompt for these if they were not specified.
118122
opts.PromptClone = !cmd.Flags().Changed("clone")

pkg/cmd/repo/fork/fork_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ func TestNewCmdFork(t *testing.T) {
144144
Rename: false,
145145
},
146146
},
147+
{
148+
name: "remote with repo argument",
149+
cli: "foo/bar --remote",
150+
wantErr: true,
151+
errMsg: "the `--remote` flag is unsupported when a repository argument is provided",
152+
},
147153
}
148154

149155
for _, tt := range tests {

0 commit comments

Comments
 (0)