[#364] Added repeatable, comma-separated and regex '--cleanup-pattern' values. - #365
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 28 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #365 +/- ##
==========================================
+ Coverage 97.00% 97.18% +0.17%
==========================================
Files 6 6
Lines 501 532 +31
==========================================
+ Hits 486 517 +31
Misses 15 15 ☔ View full report in Codecov by Harness. |
Closes #364
Summary
The
--cleanup-patternoption for stale-branch cleanup is now far more flexible. It is repeatable (InputOption::VALUE_IS_ARRAY), and each value may be a comma-separated list of shell globs (so a single environment variable likefeature/*,bugfix/*works) or a single regex literal wrapped in slashes (e.g./^feature\/[^\/]+$/). A branch is eligible for cleanup when it matches any of the supplied patterns. The change is backward compatible: a single--cleanup-pattern=deployment/*value still works exactly as before.Changes
Repeatable and comma-separated pattern parsing
--cleanup-patternis now declared withInputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAYinsrc/Commands/ArtifactCommand.php, so the flag can be passed multiple times.ArtifactCommand::resolveOptions()normalizes the raw option values: each value is trimmed, split on commas unless it is a regex literal, and empty segments are discarded.array_values(array_unique(...))and stored in a newprotected array $cleanupPatternsproperty, replacing the oldprotected string $cleanupPattern.Regex support
ArtifactGitRepository::isRegexPattern()treats a value starting with/as a PCRE literal, since a Git branch name can never begin with a slash.ArtifactGitRepository::isValidRegex()compiles a candidate pattern withpreg_match()(with a temporary error handler suppressing warnings) to confirm it is usable.RuntimeException, before any Git operations run.Matching against multiple patterns
ArtifactGitRepository::filterStaleBranches()now takesarray $patternsinstead of a singlestring $pattern.matchesAnyPattern()andmatchesPattern()iterate the pattern list, dispatching topreg_match()for regex literals or the existingmatchesGlob()for shell globs.Reporting
showInfo()now lists every resolved pattern, switching between singular and plural labels depending on the count, instead of printing a single pattern string.Documentation and tests
README.mddocuments the comma-separated and regex forms and updates the--cleanup-patternrow in the options table.tests/Functional/CleanupStaleBranchesTest.phpadds coverage for comma-separated globs, multiple--cleanup-patternflags, regex precision (excluding nested-slash branches), empty-pattern rejection, and invalid-regex rejection.tests/Unit/ArtifactGitRepositoryTest.phpadds data-provider cases for multi-pattern matching and glob/regex dedup, plus new unit tests forisRegexPattern()andisValidRegex().tests/Unit/ArtifactCommandTest.phpupdates the reflection-based property access fromcleanupPatterntocleanupPatterns.Before / After