Skip to content

Custom headerPattern not working with commit prefix #259

@marwenlandoulsi

Description

@marwenlandoulsi

Describe the bug
Custom headerPattern and headerCorrespondence configuration are not properly parsing commits that have a prefix format like [TICKET-123] type: subject.

Expected Behavior
Commits should be parsed and included in the changelog when using a custom header pattern.

Actual Behavior

  • Commits are manually tested and match the regex pattern ✅
  • But context.commits is empty during generation ❌
  • Changelog is generated but contains no commit entries ❌

Configuration

// changelog.config.js
module.exports = {
  parserOpts: {
    headerPattern: /^\[[\w-]+\]\s+(\w*)(?:\(([\w\$\.\-\* ]*)\))?\!?\: (.*)$/,
    headerCorrespondence: ['type', 'scope', 'subject'],
    noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES']
  },
  types: [
    { type: 'feat', section: 'Features' },
    { type: 'fix', section: 'Bug Fixes' }
  ]
};

Sample commits

[xxx-1208] feat!: add new feature
[xxx-1208] fix: resolve bug
[xxx-1208] feat(api): update endpoint

Environment

commit-and-tag-version version : 12.6.0
Node.js version : 22.13.1
OS : macOS

Used command
commit-and-tag-version --config ./changelog.config.js --prerelease beta --dry-run

Questions

  1. Is there a specific way custom headerPattern should be structured?
  2. Are there additional configuration options needed for custom commit formats?
  3. Could this be related to how headerCorrespondence maps the regex groups?

Workaround Attempted

  • Tried different regex variations
  • Verified commits exist in Git history
  • Tested with --first-release flag
  • Simplified configuration to minimal setup

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions