feat(labeler): add except to skip a label conditionally - #45
Conversation
Matchers within a label are OR-ed and there was no way to say "not this one". except takes the same 8 matchers plus a list of labels, any hit drops the label. Reuses the existing matchers by running them against a config view where except takes the place of matcher.
There was a problem hiding this comment.
Pull request overview
Adds an except clause to label rules so a label can be applied by normal matchers but suppressed when additional “negative” conditions match (including other matched labels). This fits the labeler’s existing model (per-label OR over matchers) by reusing the same matcher execution pipeline via an “except-as-matcher” config view.
Changes:
- Extend config schema to support
exceptas eitherstring[](labels-only shorthand) or a matcher-shaped object + optionallabels. - Implement exclusion flow in the label computation by running matchers twice (normal + except-view) and filtering matched labels accordingly.
- Document
exceptin README and add fixtures/tests for valid/invalid configs and exclusion behavior.
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/labeler.ts | Adds excludeLabels, builds an exceptConfig view, and computes final labels as mergeLabels(excludeLabels(...), config). |
| src/config.ts | Adds Except io-ts type and Label.except union to validate new config shape. |
| README.md | Documents except semantics and provides usage example including shorthand form. |
| dist/index.js | Updates built output to include new config types and exclusion logic. |
| tests/labeler.test.ts | Adds behavioral tests covering exclusion by label, title, and branch. |
| tests/fixtures/invalid/except-invalid.yml | Adds invalid fixture to ensure schema rejects non-array/non-object except. |
| tests/fixtures/except.yml | Adds valid fixture demonstrating shorthand and matcher-based except. |
| tests/config.test.ts | Adds parse tests for the new valid/invalid fixtures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (4)
📒 Files selected for processing (5)
📜 Recent review details⏰ Context from checks skipped due to timeout. (1)
🔇 Additional comments (5)
📝 WalkthroughWalkthroughAdds an ChangesExcept label matching
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant labels
participant match
participant exceptConfig
participant excludeLabels
labels->>match: evaluate original config
labels->>exceptConfig: transform except definitions
exceptConfig-->>labels: return transformed config
labels->>match: evaluate transformed config
match-->>excludeLabels: provide matched and excepted labels
excludeLabels-->>labels: return filtered labels
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What this PR does / why we need it:
Matchers within a label are OR-ed, so there was no way to express "label this, but not when ...".
exceptadds that:matcher, pluslabelsfor labels matched by another entry. Any hit drops the label.except: ['v2'].excepttakes the place of
matcher.files/commitsonly cost an extra API call when used inside anexcept.except.labelsis evaluated against the matched set, so two labels excluding each other cancel out.Keep those one directional.
Motivation: in gofiber/fiber, PRs against
mainpicked up thev2label from Go module paths likegithub.com/gofiber/utils/v2in the title, and PRs againstv2picked upv3from the body.Replaying the last 400 fiber PRs through this build with a base-branch-driven config gives 0 mismatches.
162 tests green, 4 new ones covering except by title, branch and label.
Which issue(s) does this PR fixes?:
n/a
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
exceptoption and usage examples.