From f85d0ebaedd0991294959ba99367ad6838a3ec93 Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Sun, 14 Apr 2024 12:25:01 +0100 Subject: [PATCH] Require non-empty selector when `--repo` override is used Signed-off-by: Babak K. Shandiz --- pkg/cmd/pr/update/update.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/cmd/pr/update/update.go b/pkg/cmd/pr/update/update.go index 5ce98c88f..ae78ce2fc 100644 --- a/pkg/cmd/pr/update/update.go +++ b/pkg/cmd/pr/update/update.go @@ -48,11 +48,16 @@ func NewCmdUpdate(f *cmdutil.Factory, runF func(*UpdateOptions) error) *cobra.Co Example: heredoc.Doc(` $ gh pr update 23 $ gh pr update 23 --rebase + $ gh pr update 23 --repo owner/repo `), Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { opts.Finder = shared.NewFinder(f) + if repoOverride, _ := cmd.Flags().GetString("repo"); repoOverride != "" && len(args) == 0 { + return cmdutil.FlagErrorf("argument required when using the --repo flag") + } + if len(args) > 0 { opts.SelectorArg = args[0] }