Skip to content

Commit 6490d77

Browse files
committed
Fix --repo override taking effect for pr commands
1 parent 5404fb2 commit 6490d77

File tree

10 files changed

+29
-10
lines changed

10 files changed

+29
-10
lines changed

pkg/cmd/pr/checkout/checkout.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ func NewCmdCheckout(f *cmdutil.Factory, runF func(*CheckoutOptions) error) *cobr
3636
IO: f.IOStreams,
3737
HttpClient: f.HttpClient,
3838
Config: f.Config,
39-
BaseRepo: f.BaseRepo,
4039
Remotes: f.Remotes,
4140
Branch: f.Branch,
4241
}
@@ -51,6 +50,9 @@ func NewCmdCheckout(f *cmdutil.Factory, runF func(*CheckoutOptions) error) *cobr
5150
return nil
5251
},
5352
RunE: func(cmd *cobra.Command, args []string) error {
53+
// support `-R, --repo` override
54+
opts.BaseRepo = f.BaseRepo
55+
5456
if len(args) > 0 {
5557
opts.SelectorArg = args[0]
5658
}

pkg/cmd/pr/close/close.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ func NewCmdClose(f *cmdutil.Factory, runF func(*CloseOptions) error) *cobra.Comm
2828
IO: f.IOStreams,
2929
HttpClient: f.HttpClient,
3030
Config: f.Config,
31-
BaseRepo: f.BaseRepo,
3231
}
3332

3433
cmd := &cobra.Command{
3534
Use: "close {<number> | <url> | <branch>}",
3635
Short: "Close a pull request",
3736
Args: cobra.ExactArgs(1),
3837
RunE: func(cmd *cobra.Command, args []string) error {
38+
// support `-R, --repo` override
39+
opts.BaseRepo = f.BaseRepo
40+
3941
if len(args) > 0 {
4042
opts.SelectorArg = args[0]
4143
}

pkg/cmd/pr/diff/diff.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ func NewCmdDiff(f *cmdutil.Factory, runF func(*DiffOptions) error) *cobra.Comman
3131
opts := &DiffOptions{
3232
IO: f.IOStreams,
3333
HttpClient: f.HttpClient,
34-
BaseRepo: f.BaseRepo,
3534
Remotes: f.Remotes,
3635
Branch: f.Branch,
3736
}
@@ -41,6 +40,9 @@ func NewCmdDiff(f *cmdutil.Factory, runF func(*DiffOptions) error) *cobra.Comman
4140
Short: "View changes in a pull request",
4241
Args: cobra.MaximumNArgs(1),
4342
RunE: func(cmd *cobra.Command, args []string) error {
43+
// support `-R, --repo` override
44+
opts.BaseRepo = f.BaseRepo
45+
4446
if len(args) > 0 {
4547
opts.SelectorArg = args[0]
4648
}

pkg/cmd/pr/list/list.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
3333
opts := &ListOptions{
3434
IO: f.IOStreams,
3535
HttpClient: f.HttpClient,
36-
BaseRepo: f.BaseRepo,
3736
}
3837

3938
cmd := &cobra.Command{
@@ -47,6 +46,9 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
4746
`),
4847
Args: cmdutil.NoArgsQuoteReminder,
4948
RunE: func(cmd *cobra.Command, args []string) error {
49+
// support `-R, --repo` override
50+
opts.BaseRepo = f.BaseRepo
51+
5052
if opts.LimitResults < 1 {
5153
return &cmdutil.FlagError{Err: fmt.Errorf("invalid value for --limit: %v", opts.LimitResults)}
5254
}

pkg/cmd/pr/merge/merge.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func NewCmdMerge(f *cmdutil.Factory, runF func(*MergeOptions) error) *cobra.Comm
4040
IO: f.IOStreams,
4141
HttpClient: f.HttpClient,
4242
Config: f.Config,
43-
BaseRepo: f.BaseRepo,
4443
Remotes: f.Remotes,
4544
Branch: f.Branch,
4645
}
@@ -62,6 +61,9 @@ func NewCmdMerge(f *cmdutil.Factory, runF func(*MergeOptions) error) *cobra.Comm
6261
`),
6362
Args: cobra.MaximumNArgs(1),
6463
RunE: func(cmd *cobra.Command, args []string) error {
64+
// support `-R, --repo` override
65+
opts.BaseRepo = f.BaseRepo
66+
6567
if len(args) > 0 {
6668
opts.SelectorArg = args[0]
6769
}

pkg/cmd/pr/ready/ready.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ func NewCmdReady(f *cmdutil.Factory, runF func(*ReadyOptions) error) *cobra.Comm
3131
IO: f.IOStreams,
3232
HttpClient: f.HttpClient,
3333
Config: f.Config,
34-
BaseRepo: f.BaseRepo,
3534
Remotes: f.Remotes,
3635
Branch: f.Branch,
3736
}
@@ -41,6 +40,9 @@ func NewCmdReady(f *cmdutil.Factory, runF func(*ReadyOptions) error) *cobra.Comm
4140
Short: "Mark a pull request as ready for review",
4241
Args: cobra.MaximumNArgs(1),
4342
RunE: func(cmd *cobra.Command, args []string) error {
43+
// support `-R, --repo` override
44+
opts.BaseRepo = f.BaseRepo
45+
4446
if len(args) > 0 {
4547
opts.SelectorArg = args[0]
4648
}

pkg/cmd/pr/reopen/reopen.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ func NewCmdReopen(f *cmdutil.Factory, runF func(*ReopenOptions) error) *cobra.Co
2828
IO: f.IOStreams,
2929
HttpClient: f.HttpClient,
3030
Config: f.Config,
31-
BaseRepo: f.BaseRepo,
3231
}
3332

3433
cmd := &cobra.Command{
3534
Use: "reopen {<number> | <url> | <branch>}",
3635
Short: "Reopen a pull request",
3736
Args: cobra.ExactArgs(1),
3837
RunE: func(cmd *cobra.Command, args []string) error {
38+
// support `-R, --repo` override
39+
opts.BaseRepo = f.BaseRepo
40+
3941
if len(args) > 0 {
4042
opts.SelectorArg = args[0]
4143
}

pkg/cmd/pr/review/review.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func NewCmdReview(f *cmdutil.Factory, runF func(*ReviewOptions) error) *cobra.Co
4040
IO: f.IOStreams,
4141
HttpClient: f.HttpClient,
4242
Config: f.Config,
43-
BaseRepo: f.BaseRepo,
4443
Remotes: f.Remotes,
4544
Branch: f.Branch,
4645
}
@@ -68,6 +67,9 @@ func NewCmdReview(f *cmdutil.Factory, runF func(*ReviewOptions) error) *cobra.Co
6867
`),
6968
Args: cobra.MaximumNArgs(1),
7069
RunE: func(cmd *cobra.Command, args []string) error {
70+
// support `-R, --repo` override
71+
opts.BaseRepo = f.BaseRepo
72+
7173
if len(args) > 0 {
7274
opts.SelectorArg = args[0]
7375
}

pkg/cmd/pr/status/status.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ func NewCmdStatus(f *cmdutil.Factory, runF func(*StatusOptions) error) *cobra.Co
3838
IO: f.IOStreams,
3939
HttpClient: f.HttpClient,
4040
Config: f.Config,
41-
BaseRepo: f.BaseRepo,
4241
Remotes: f.Remotes,
4342
Branch: f.Branch,
4443
}
@@ -48,6 +47,8 @@ func NewCmdStatus(f *cmdutil.Factory, runF func(*StatusOptions) error) *cobra.Co
4847
Short: "Show status of relevant pull requests",
4948
Args: cmdutil.NoArgsQuoteReminder,
5049
RunE: func(cmd *cobra.Command, args []string) error {
50+
// support `-R, --repo` override
51+
opts.BaseRepo = f.BaseRepo
5152
opts.HasRepoOverride = cmd.Flags().Changed("repo")
5253

5354
if runF != nil {

pkg/cmd/pr/view/view.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ func NewCmdView(f *cmdutil.Factory, runF func(*ViewOptions) error) *cobra.Comman
3636
IO: f.IOStreams,
3737
HttpClient: f.HttpClient,
3838
Config: f.Config,
39-
BaseRepo: f.BaseRepo,
4039
Remotes: f.Remotes,
4140
Branch: f.Branch,
4241
}
@@ -54,6 +53,9 @@ func NewCmdView(f *cmdutil.Factory, runF func(*ViewOptions) error) *cobra.Comman
5453
`),
5554
Args: cobra.MaximumNArgs(1),
5655
RunE: func(cmd *cobra.Command, args []string) error {
56+
// support `-R, --repo` override
57+
opts.BaseRepo = f.BaseRepo
58+
5759
if len(args) > 0 {
5860
opts.SelectorArg = args[0]
5961
}

0 commit comments

Comments
 (0)