Skip to content

Commit 6cc03d3

Browse files
authored
Merge pull request cli#1253 from cli/remove-global-repo-flag-for-real-this-time
Remove the global repo flag
2 parents ed78110 + cd5a0d6 commit 6cc03d3

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

command/issue.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
)
2323

2424
func init() {
25+
issueCmd.PersistentFlags().StringP("repo", "R", "", "Select another repository using the `OWNER/REPO` format")
26+
2527
RootCmd.AddCommand(issueCmd)
2628
issueCmd.AddCommand(issueStatusCmd)
2729

command/pr.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import (
2323
)
2424

2525
func init() {
26+
prCmd.PersistentFlags().StringP("repo", "R", "", "Select another repository using the `OWNER/REPO` format")
27+
2628
RootCmd.AddCommand(prCmd)
2729
prCmd.AddCommand(prCheckoutCmd)
2830
prCmd.AddCommand(prCreateCmd)

command/root.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ func init() {
5252
RootCmd.AddCommand(versionCmd)
5353
RootCmd.SetVersionTemplate(versionOutput)
5454

55-
RootCmd.PersistentFlags().StringP("repo", "R", "", "Select another repository using the `OWNER/REPO` format")
5655
RootCmd.PersistentFlags().Bool("help", false, "Show help for command")
5756
RootCmd.Flags().Bool("version", false, "Show gh version")
5857
// TODO:
@@ -304,26 +303,21 @@ func changelogURL(version string) string {
304303
}
305304

306305
func determineBaseRepo(apiClient *api.Client, cmd *cobra.Command, ctx context.Context) (ghrepo.Interface, error) {
307-
repo, err := cmd.Flags().GetString("repo")
308-
if err == nil && repo != "" {
306+
repo, _ := cmd.Flags().GetString("repo")
307+
if repo != "" {
309308
baseRepo, err := ghrepo.FromFullName(repo)
310309
if err != nil {
311310
return nil, fmt.Errorf("argument error: %w", err)
312311
}
313312
return baseRepo, nil
314313
}
315314

316-
baseOverride, err := cmd.Flags().GetString("repo")
317-
if err != nil {
318-
return nil, err
319-
}
320-
321315
remotes, err := ctx.Remotes()
322316
if err != nil {
323317
return nil, err
324318
}
325319

326-
repoContext, err := context.ResolveRemotesToRepos(remotes, apiClient, baseOverride)
320+
repoContext, err := context.ResolveRemotesToRepos(remotes, apiClient, "")
327321
if err != nil {
328322
return nil, err
329323
}

0 commit comments

Comments
 (0)