Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration uses regex for conventional commit scope #266

Open
syaghoubi00 opened this issue Dec 25, 2024 · 0 comments
Open

Configuration uses regex for conventional commit scope #266

syaghoubi00 opened this issue Dec 25, 2024 · 0 comments

Comments

@syaghoubi00
Copy link
Contributor

The current scope parsing behavior returns true if the scope contains the regex pattern, not if the scope is an exact match.

.conform.yaml

policies:
  - type: commit
    spec:
      conventional:
        types: ["type"]
        scopes: ["a"]
git commit --allow-empty -m "type(aa): some message"
POLICY         CHECK                      STATUS        MESSAGE
commit         Conventional Commit        PASS          Commit message is a valid conventional commit
license        File Header                PASS          All files have a valid license header

Using the exact match regex in the config;
.conform.yaml

policies:
  - type: commit
    spec:
      conventional:
        types: ["type"]
        scopes: ["^a$"]
git commit --allow-empty -m "type(aa): some message"
POLICY         CHECK                      STATUS        MESSAGE                           
commit         Conventional Commit        FAILED        Invalid scope "aa": allowed scopes are [^a$]
license        File Header                PASS          All files have a valid license header
Error: 1 or more policy failed

The regex could be useful for defining more complex scope patterns, but it doesn't match what I would call expected behavior since the types: key doesn't use regex. Perhaps it would be better to add a regex: bool option to the config and do a non-regex scope match by default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant