Skip to content

Commit

Permalink
feat!: better, stricter regex matching (commit msgs)
Browse files Browse the repository at this point in the history
Be more compliant with the Conventional Commits spec, while still
allowing some typos/slight variations (e.g. in whitespace).

NOT using an external parser because:
  - we don't need the entire commit message parsed for our use-case

  - the few parsers currently around vary, might throw if the entire
    commit message isn't exactly compliant with spec, might error
    erroneously if parser is too strict while having an imperfect
    grammar (e.g. when it comes to git trailers), etc.

  - it would add a dependency, and may complicate things unnecessarily

BREAKING CHANGE: the regex/pattern used for detecting "breaking change"
commit messages has changed. `BREAKING` alone is no longer detected, use
`BREAKING CHANGE` instead. Please see this commit's diff for details.
  • Loading branch information
tmillr committed Dec 27, 2022
1 parent ca74af5 commit ae8a878
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export function humanReadableTypeOf(obj) {

/** Filters out non-breaking-change commits based on their message */
export const filterFn = (msg) =>
/^[^:]+!:/u.test(msg.trim().split("\n")[0]) || /^\s*BREAKING/mu.test(msg);
/^[^:()]+(?:\([^()]*\))?!:/u.test(msg.trim().split("\n")[0]) ||
/^[ \t]*BREAKING([ \t]*|-)CHANGE[ \t]*:/mu.test(msg);

export function getOctokit(
auth = core.getInput("token", {
Expand Down

0 comments on commit ae8a878

Please sign in to comment.