Skip to content

Commit 081f195

Browse files
committed
move inputs to its own file and make sure its params match
1 parent 4f0ed87 commit 081f195

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

internal/cmd/inputs.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package cmd
2+
3+
import "errors"
4+
5+
// validateInputs checks if the provided inputs are valid
6+
func ValidateInputs(args []string) error {
7+
// Check that ignore-label and select-label are not the same
8+
if ignoreLabel != "" && selectLabel != "" && ignoreLabel == selectLabel {
9+
return errors.New("--ignore-label(s) and --label(s) cannot have the same value")
10+
}
11+
12+
// If no args and no file, we can't proceed
13+
if len(args) == 0 && reposFile == "" {
14+
return errors.New("must specify repositories or provide a file with --file")
15+
}
16+
17+
// Warn if no filtering options are provided at all
18+
if branchPrefix == "" && branchSuffix == "" && branchRegex == "" &&
19+
ignoreLabel == "" && selectLabel == "" && len(selectLabels) == 0 &&
20+
!requireCI && !mustBeApproved {
21+
Logger.Warn("No filtering options specified. This will attempt to combine ALL open pull requests.")
22+
}
23+
24+
return nil
25+
}

internal/cmd/root.go

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func runCombine(cmd *cobra.Command, args []string) error {
126126
Logger.Debug("starting gh-combine", "version", version.String())
127127

128128
// Input validation
129-
if err := validateInputs(args); err != nil {
129+
if err := ValidateInputs(args); err != nil {
130130
return err
131131
}
132132

@@ -170,28 +170,6 @@ func setupSignalContext() (context.Context, context.CancelFunc) {
170170
return ctx, cancel
171171
}
172172

173-
// validateInputs checks if the provided inputs are valid
174-
func validateInputs(args []string) error {
175-
// Check that ignore-label and select-label are not the same
176-
if ignoreLabel != "" && selectLabel != "" && ignoreLabel == selectLabel {
177-
return errors.New("--ignore-label and --select-label cannot have the same value")
178-
}
179-
180-
// If no args and no file, we can't proceed
181-
if len(args) == 0 && reposFile == "" {
182-
return errors.New("must specify repositories or provide a file with --file")
183-
}
184-
185-
// Warn if no filtering options are provided at all
186-
if branchPrefix == "" && branchSuffix == "" && branchRegex == "" &&
187-
ignoreLabel == "" && selectLabel == "" && len(selectLabels) == 0 &&
188-
!requireCI && !mustBeApproved {
189-
Logger.Warn("No filtering options specified. This will attempt to combine ALL open pull requests.")
190-
}
191-
192-
return nil
193-
}
194-
195173
// parseRepositories parses repository names from arguments or file
196174
func parseRepositories(args []string) ([]string, error) {
197175
var repos []string

0 commit comments

Comments
 (0)