Merge pull request #12375 from majiayu000/2722-fix-fork-remote-flag

fix: error when --remote flag used with repo argument
This commit is contained in:
Kynan Ware 2026-03-02 10:34:02 -07:00 committed by GitHub
commit 628dea6e52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View file

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

View file

@ -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 {