7
7
"strings"
8
8
9
9
"github.com/cli/go-gh/v2/pkg/api"
10
+
10
11
"github.com/spf13/cobra"
11
12
12
13
"github.com/github/gh-combine/internal/version"
28
29
ignoreLabels []string
29
30
reposFile string
30
31
minimum int
32
+ defaultOwner string
31
33
)
32
34
33
35
// NewRootCmd creates the root command for the gh-combine CLI
@@ -36,41 +38,50 @@ func NewRootCmd() *cobra.Command {
36
38
Use : "combine [repo1,repo2,...]" ,
37
39
Short : "Combine multiple pull requests into a single PR" ,
38
40
Long : `Combine multiple pull requests that match specific criteria into a single PR.
39
- Examples:
40
- # Basic usage with a single repository
41
- gh combine octocat/hello-world
42
-
43
- # Multiple repositories (comma-separated)
44
- gh combine octocat/repo1,octocat/repo2
45
-
46
- # Using a file with repository names (one per line)
47
- gh combine --file repos.txt
48
-
49
- # Filter PRs by branch name
50
- gh combine octocat/hello-world --branch-prefix dependabot-
51
- gh combine octocat/hello-world --branch-suffix -update
52
- gh combine octocat/hello-world --branch-regex "dependabot/.*"
53
-
54
- # Filter PRs by labels
55
- gh combine octocat/hello-world --label dependencies # PRs must have this single label
56
- gh combine octocat/hello-world --labels security,dependencies # PRs must have ALL these labels
57
-
58
- # Exclude PRs by labels
59
- gh combine octocat/hello-world --ignore-label wip # Ignore PRs with this label
60
- gh combine octocat/hello-world --ignore-labels wip,draft # Ignore PRs with ANY of these labels
61
-
62
- # Set requirements for PRs to be combined
63
- gh combine octocat/hello-world --require-ci # Only include PRs with passing CI
64
- gh combine octocat/hello-world --require-approved # Only include approved PRs
65
- gh combine octocat/hello-world --minimum 3 # Need at least 3 matching PRs
66
-
67
- # Add metadata to combined PR
68
- gh combine octocat/hello-world --add-labels security,dependencies # Add these labels to the new PR
69
- gh combine octocat/hello-world --assignees octocat,hubot # Assign users to the new PR
70
-
71
- # Additional options
72
- gh combine octocat/hello-world --autoclose # Close source PRs when combined PR is merged
73
- gh combine octocat/hello-world --update-branch # Update the branch of the combined PR` ,
41
+ Examples:
42
+ # Basic usage with a single repository
43
+ gh combine octocat/hello-world
44
+
45
+ # Multiple repositories (comma-separated)
46
+ gh combine octocat/repo1,octocat/repo2
47
+
48
+ # Multiple repositories (no commas)
49
+ gh combine octocat/repo1 octocat/repo2
50
+
51
+ # Using default owner for repositories
52
+ gh combine --owner octocat repo1 repo2
53
+
54
+ # Using default owner for only some repositories
55
+ gh combine --owner octocat repo1 octocat/repo2
56
+
57
+ # Using a file with repository names (one per line: owner/repo format)
58
+ gh combine --file repos.txt
59
+
60
+ # Filter PRs by branch name
61
+ gh combine octocat/hello-world --branch-prefix dependabot/
62
+ gh combine octocat/hello-world --branch-suffix -update
63
+ gh combine octocat/hello-world --branch-regex "dependabot/.*"
64
+
65
+ # Filter PRs by labels
66
+ gh combine octocat/hello-world --label dependencies # PRs must have this single label
67
+ gh combine octocat/hello-world --labels security,dependencies # PRs must have ALL these labels
68
+
69
+ # Exclude PRs by labels
70
+ gh combine octocat/hello-world --ignore-label wip # Ignore PRs with this label
71
+ gh combine octocat/hello-world --ignore-labels wip,draft # Ignore PRs with ANY of these labels
72
+
73
+ # Set requirements for PRs to be combined
74
+ gh combine octocat/hello-world --require-ci # Only include PRs with passing CI
75
+ gh combine octocat/hello-world --require-approved # Only include approved PRs
76
+ gh combine octocat/hello-world --minimum 3 # Need at least 3 matching PRs
77
+
78
+ # Add metadata to combined PR
79
+ gh combine octocat/hello-world --add-labels security,dependencies # Add these labels to the new PR
80
+ gh combine octocat/hello-world --assignees octocat,hubot # Assign users to the new PR
81
+
82
+ # Additional options
83
+ gh combine octocat/hello-world --autoclose # Close source PRs when combined PR is merged
84
+ gh combine octocat/hello-world --update-branch # Update the branch of the combined PR` ,
74
85
RunE : runCombine ,
75
86
}
76
87
@@ -98,6 +109,7 @@ func NewRootCmd() *cobra.Command {
98
109
rootCmd .Flags ().BoolVar (& updateBranch , "update-branch" , false , "Update the branch of the combined PR if possible" )
99
110
rootCmd .Flags ().StringVar (& reposFile , "file" , "" , "File containing repository names, one per line" )
100
111
rootCmd .Flags ().IntVar (& minimum , "minimum" , 2 , "Minimum number of PRs to combine" )
112
+ rootCmd .Flags ().StringVar (& defaultOwner , "owner" , "" , "Default owner for repositories (if not specified in repo name or missing from file inputs)" )
101
113
102
114
// Add deprecated flags for backward compatibility
103
115
// rootCmd.Flags().IntVar(&minimum, "min-combine", 2, "Minimum number of PRs to combine (deprecated, use --minimum)")
@@ -130,7 +142,7 @@ func runCombine(cmd *cobra.Command, args []string) error {
130
142
defer spinner .Stop ()
131
143
132
144
// Parse repositories from args or file
133
- repos , err := ParseRepositories (args , reposFile )
145
+ repos , err := ParseRepositories (args , reposFile , defaultOwner )
134
146
if err != nil {
135
147
return fmt .Errorf ("failed to parse repositories: %w" , err )
136
148
}
0 commit comments