From 6490d7717c0916284dbc9855a0e728f436cb86fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 6 Aug 2020 21:39:46 +0200 Subject: [PATCH] Fix `--repo` override taking effect for `pr` commands --- pkg/cmd/pr/checkout/checkout.go | 4 +++- pkg/cmd/pr/close/close.go | 4 +++- pkg/cmd/pr/diff/diff.go | 4 +++- pkg/cmd/pr/list/list.go | 4 +++- pkg/cmd/pr/merge/merge.go | 4 +++- pkg/cmd/pr/ready/ready.go | 4 +++- pkg/cmd/pr/reopen/reopen.go | 4 +++- pkg/cmd/pr/review/review.go | 4 +++- pkg/cmd/pr/status/status.go | 3 ++- pkg/cmd/pr/view/view.go | 4 +++- 10 files changed, 29 insertions(+), 10 deletions(-) diff --git a/pkg/cmd/pr/checkout/checkout.go b/pkg/cmd/pr/checkout/checkout.go index 20eef580c..23c4bb70b 100644 --- a/pkg/cmd/pr/checkout/checkout.go +++ b/pkg/cmd/pr/checkout/checkout.go @@ -36,7 +36,6 @@ func NewCmdCheckout(f *cmdutil.Factory, runF func(*CheckoutOptions) error) *cobr IO: f.IOStreams, HttpClient: f.HttpClient, Config: f.Config, - BaseRepo: f.BaseRepo, Remotes: f.Remotes, Branch: f.Branch, } @@ -51,6 +50,9 @@ func NewCmdCheckout(f *cmdutil.Factory, runF func(*CheckoutOptions) error) *cobr return nil }, RunE: func(cmd *cobra.Command, args []string) error { + // support `-R, --repo` override + opts.BaseRepo = f.BaseRepo + if len(args) > 0 { opts.SelectorArg = args[0] } diff --git a/pkg/cmd/pr/close/close.go b/pkg/cmd/pr/close/close.go index 9bce6bb5d..2fba67e06 100644 --- a/pkg/cmd/pr/close/close.go +++ b/pkg/cmd/pr/close/close.go @@ -28,7 +28,6 @@ func NewCmdClose(f *cmdutil.Factory, runF func(*CloseOptions) error) *cobra.Comm IO: f.IOStreams, HttpClient: f.HttpClient, Config: f.Config, - BaseRepo: f.BaseRepo, } cmd := &cobra.Command{ @@ -36,6 +35,9 @@ func NewCmdClose(f *cmdutil.Factory, runF func(*CloseOptions) error) *cobra.Comm Short: "Close a pull request", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { + // support `-R, --repo` override + opts.BaseRepo = f.BaseRepo + if len(args) > 0 { opts.SelectorArg = args[0] } diff --git a/pkg/cmd/pr/diff/diff.go b/pkg/cmd/pr/diff/diff.go index c38e7c78b..3d9d32083 100644 --- a/pkg/cmd/pr/diff/diff.go +++ b/pkg/cmd/pr/diff/diff.go @@ -31,7 +31,6 @@ func NewCmdDiff(f *cmdutil.Factory, runF func(*DiffOptions) error) *cobra.Comman opts := &DiffOptions{ IO: f.IOStreams, HttpClient: f.HttpClient, - BaseRepo: f.BaseRepo, Remotes: f.Remotes, Branch: f.Branch, } @@ -41,6 +40,9 @@ func NewCmdDiff(f *cmdutil.Factory, runF func(*DiffOptions) error) *cobra.Comman Short: "View changes in a pull request", Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { + // support `-R, --repo` override + opts.BaseRepo = f.BaseRepo + if len(args) > 0 { opts.SelectorArg = args[0] } diff --git a/pkg/cmd/pr/list/list.go b/pkg/cmd/pr/list/list.go index da8a04857..fd1ebb2b9 100644 --- a/pkg/cmd/pr/list/list.go +++ b/pkg/cmd/pr/list/list.go @@ -33,7 +33,6 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman opts := &ListOptions{ IO: f.IOStreams, HttpClient: f.HttpClient, - BaseRepo: f.BaseRepo, } cmd := &cobra.Command{ @@ -47,6 +46,9 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman `), Args: cmdutil.NoArgsQuoteReminder, RunE: func(cmd *cobra.Command, args []string) error { + // support `-R, --repo` override + opts.BaseRepo = f.BaseRepo + if opts.LimitResults < 1 { return &cmdutil.FlagError{Err: fmt.Errorf("invalid value for --limit: %v", opts.LimitResults)} } diff --git a/pkg/cmd/pr/merge/merge.go b/pkg/cmd/pr/merge/merge.go index 00aa25695..b3c20b208 100644 --- a/pkg/cmd/pr/merge/merge.go +++ b/pkg/cmd/pr/merge/merge.go @@ -40,7 +40,6 @@ func NewCmdMerge(f *cmdutil.Factory, runF func(*MergeOptions) error) *cobra.Comm IO: f.IOStreams, HttpClient: f.HttpClient, Config: f.Config, - BaseRepo: f.BaseRepo, Remotes: f.Remotes, Branch: f.Branch, } @@ -62,6 +61,9 @@ func NewCmdMerge(f *cmdutil.Factory, runF func(*MergeOptions) error) *cobra.Comm `), Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { + // support `-R, --repo` override + opts.BaseRepo = f.BaseRepo + if len(args) > 0 { opts.SelectorArg = args[0] } diff --git a/pkg/cmd/pr/ready/ready.go b/pkg/cmd/pr/ready/ready.go index ab5989267..c5a248f19 100644 --- a/pkg/cmd/pr/ready/ready.go +++ b/pkg/cmd/pr/ready/ready.go @@ -31,7 +31,6 @@ func NewCmdReady(f *cmdutil.Factory, runF func(*ReadyOptions) error) *cobra.Comm IO: f.IOStreams, HttpClient: f.HttpClient, Config: f.Config, - BaseRepo: f.BaseRepo, Remotes: f.Remotes, Branch: f.Branch, } @@ -41,6 +40,9 @@ func NewCmdReady(f *cmdutil.Factory, runF func(*ReadyOptions) error) *cobra.Comm Short: "Mark a pull request as ready for review", Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { + // support `-R, --repo` override + opts.BaseRepo = f.BaseRepo + if len(args) > 0 { opts.SelectorArg = args[0] } diff --git a/pkg/cmd/pr/reopen/reopen.go b/pkg/cmd/pr/reopen/reopen.go index b71587250..78f4a36ec 100644 --- a/pkg/cmd/pr/reopen/reopen.go +++ b/pkg/cmd/pr/reopen/reopen.go @@ -28,7 +28,6 @@ func NewCmdReopen(f *cmdutil.Factory, runF func(*ReopenOptions) error) *cobra.Co IO: f.IOStreams, HttpClient: f.HttpClient, Config: f.Config, - BaseRepo: f.BaseRepo, } cmd := &cobra.Command{ @@ -36,6 +35,9 @@ func NewCmdReopen(f *cmdutil.Factory, runF func(*ReopenOptions) error) *cobra.Co Short: "Reopen a pull request", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { + // support `-R, --repo` override + opts.BaseRepo = f.BaseRepo + if len(args) > 0 { opts.SelectorArg = args[0] } diff --git a/pkg/cmd/pr/review/review.go b/pkg/cmd/pr/review/review.go index 61bfcea59..dba5dff10 100644 --- a/pkg/cmd/pr/review/review.go +++ b/pkg/cmd/pr/review/review.go @@ -40,7 +40,6 @@ func NewCmdReview(f *cmdutil.Factory, runF func(*ReviewOptions) error) *cobra.Co IO: f.IOStreams, HttpClient: f.HttpClient, Config: f.Config, - BaseRepo: f.BaseRepo, Remotes: f.Remotes, Branch: f.Branch, } @@ -68,6 +67,9 @@ func NewCmdReview(f *cmdutil.Factory, runF func(*ReviewOptions) error) *cobra.Co `), Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { + // support `-R, --repo` override + opts.BaseRepo = f.BaseRepo + if len(args) > 0 { opts.SelectorArg = args[0] } diff --git a/pkg/cmd/pr/status/status.go b/pkg/cmd/pr/status/status.go index 8708dae65..dffd2b412 100644 --- a/pkg/cmd/pr/status/status.go +++ b/pkg/cmd/pr/status/status.go @@ -38,7 +38,6 @@ func NewCmdStatus(f *cmdutil.Factory, runF func(*StatusOptions) error) *cobra.Co IO: f.IOStreams, HttpClient: f.HttpClient, Config: f.Config, - BaseRepo: f.BaseRepo, Remotes: f.Remotes, Branch: f.Branch, } @@ -48,6 +47,8 @@ func NewCmdStatus(f *cmdutil.Factory, runF func(*StatusOptions) error) *cobra.Co Short: "Show status of relevant pull requests", Args: cmdutil.NoArgsQuoteReminder, RunE: func(cmd *cobra.Command, args []string) error { + // support `-R, --repo` override + opts.BaseRepo = f.BaseRepo opts.HasRepoOverride = cmd.Flags().Changed("repo") if runF != nil { diff --git a/pkg/cmd/pr/view/view.go b/pkg/cmd/pr/view/view.go index b93bfcd1d..169d989f1 100644 --- a/pkg/cmd/pr/view/view.go +++ b/pkg/cmd/pr/view/view.go @@ -36,7 +36,6 @@ func NewCmdView(f *cmdutil.Factory, runF func(*ViewOptions) error) *cobra.Comman IO: f.IOStreams, HttpClient: f.HttpClient, Config: f.Config, - BaseRepo: f.BaseRepo, Remotes: f.Remotes, Branch: f.Branch, } @@ -54,6 +53,9 @@ func NewCmdView(f *cmdutil.Factory, runF func(*ViewOptions) error) *cobra.Comman `), Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { + // support `-R, --repo` override + opts.BaseRepo = f.BaseRepo + if len(args) > 0 { opts.SelectorArg = args[0] }