Skip to content

ci: automate PR title linting - #229

Merged
johannschopplich merged 2 commits into
toon-format:mainfrom
okineadev:pr-title-linting
Dec 1, 2025
Merged

ci: automate PR title linting#229
johannschopplich merged 2 commits into
toon-format:mainfrom
okineadev:pr-title-linting

Conversation

@okineadev

Copy link
Copy Markdown
Contributor

This will help with Squash & Merge when you need the squashed commit to have the correct Conventional Commits format so that it can be parsed when generating release notes

(With Squash & Merge the squashed commit message is taken from the PR title)

This will help with Squash & Merge when you need the squashed commit to have the correct Conventional Commits format so that it can be parsed when generating release notes

(With Squash & Merge the squashed commit message is taken from the PR title)
@johannschopplich

Copy link
Copy Markdown
Collaborator

I like the idea! However, could we simplify the approch with a simple script, as does Vite in its Git hooks?

const RELEASE_RE = /^v\d/
const COMMIT_RE =
  /^(revert: )?(feat|fix|docs|style|refactor|perf|test|build|ci|chore)(\(.+\))?!?: .{1,50}/

if (!RELEASE_RE.test(msg) && !COMMIT_RE.test(msg)) {
  console.log()
  console.error(
    `  ${colors.bgRed(colors.white(' ERROR '))} ${colors.red(
      'invalid commit message format.',
    )}\n\n${colors.red(
      '  Proper commit message format is required for automated changelog generation. Examples:\n\n',
    )}    ${colors.green('feat: add `comments` option')}\n` +
      `    ${colors.green(
        'fix: handle events on blur (close #28)',
      )}\n\n${colors.red(
        '  See .github/commit-convention.md for more details.\n',
      )}`,
  )
  process.exit(1)
}

I'd much prefer the most simplest solution instead of new dependencies.

@okineadev

Copy link
Copy Markdown
Contributor Author

I like the idea! However, could we simplify the approch with a simple script, as does Vite in its Git hooks?

const RELEASE_RE = /^v\d/
const COMMIT_RE =
  /^(revert: )?(feat|fix|docs|style|refactor|perf|test|build|ci|chore)(\(.+\))?!?: .{1,50}/

if (!RELEASE_RE.test(msg) && !COMMIT_RE.test(msg)) {
  console.log()
  console.error(
    `  ${colors.bgRed(colors.white(' ERROR '))} ${colors.red(
      'invalid commit message format.',
    )}\n\n${colors.red(
      '  Proper commit message format is required for automated changelog generation. Examples:\n\n',
    )}    ${colors.green('feat: add `comments` option')}\n` +
      `    ${colors.green(
        'fix: handle events on blur (close #28)',
      )}\n\n${colors.red(
        '  See .github/commit-convention.md for more details.\n',
      )}`,
  )
  process.exit(1)
}

I'd much prefer the most simplest solution instead of new dependencies.

I would agree with you, but in my opinion it is better to use commitlint.

Firstly it does not add any dependencies to the project except simple types for config, and commitlint itself is only installed temporarily in the GitHub Actions environment without cluttering the project itself
Secondly it provides more flexibility and clearly tells what exactly is wrong in the commit message (e.g. type or subject, etc.), you can customize the rules so that, for example, it doesn't throw an error but a warning

@johannschopplich

Copy link
Copy Markdown
Collaborator

Thanks for the explanation, I see your point. I agree, let's use commitlint. Thanks for the input!

@johannschopplich
johannschopplich merged commit 7ed9701 into toon-format:main Dec 1, 2025
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants