feat: add support for regex patterns in scopes - #982
Open
yarinvak wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR enhances the scope validation in semantic-prs to support regex patterns in addition to exact string matches. This allows for more flexible scope configurations, particularly useful for ticket-based workflows.
Motivation
Previously, scopes could only be validated against exact string matches. This meant that for ticket-based workflows (e.g., JIRA tickets, GitHub issues), every possible ticket ID would need to be listed in the configuration, which is impractical. With regex support, you can now define patterns like COR- to match any ticket starting with that prefix.
Changes
✨ Enhanced scope validation logic in is-message-semantic.ts to support regex patterns
🧪 Added comprehensive test coverage for regex scope matching (8 new test cases)
📝 Updated README documentation to explain the new regex functionality
🛡️ Added graceful error handling for invalid regex patterns
How It Works
The validation logic now follows this approach:
First attempts an exact string match
If no exact match is found, treats the scope as a regex pattern
Invalid regex patterns are handled gracefully and fall back to exact match only
Configuration Example
Testing
All existing tests continue to pass
Added 8 new test cases covering:
Breaking Changes
None. This change is fully backward compatible - existing configurations will continue to work exactly as before.
Examples
✅ Valid commit messages with regex scopes:
feat(COR-1234): implement new featurefix(JIRA-5678): resolve bug in authenticationdocs(COR-999,auth): update API documentation