semantic-release / semantic-release/commit-analyzer

Can Commit-Analyzer handle 2 different commit structure?

Open
#294 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
448
Forks
82
Avg merge
17h 41m
Merged PRs (30d)
4

Description

Let's say I have a commit which look like that:
fix: this is an example
Commit-analyzer is detecting this commit and triggers a patch version - which is the expected behaviour.

Then I complete a PR which creates a new commit:
Merged PR 11111: fix: this is another example
Commit-analyzer can't detect the commit fix: this is another example because of the prefix that Azure Devops adds to the commit it generates when completing a PR (Merged PR 1111: ). So I have found the mergePattern property inside parserOpts and I added a regex that inform commit-analyzer about the prefix:

parserOpts: {
   mergePattern: /^Merged PR (\d+): (\w*)(?:\(([\w\$\.\-\* ]*)\))?\: (.*)((.|\n)*)/,  
   mergeCorrespondence: ['id', 'type', 'scope', 'subject'],
   noteKeywords: ["BREAKING CHANGE", "BREAKING CHANGES"]
}

Now commit-analyzer has been able to detect the relevant commit content within this commit structure.

My problem is that now, with the mergePattern attribute defined to look for specific structure - a regular commit such as the first example fix: this is an example won't be considered as a valid commit and no version will be triggered.

There is an option to support both types of commits? with and without Merged PR #####: prefix?

Thanks.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading how parserOpts.mergePattern and mergeCorrespondence are applied to commit messages. Check the existing commit-analyzer behavior for both a plain fix: commit and an Azure DevOps Merged PR #####: fix: commit. Done means both structures are recognized and trigger the expected version analysis without requiring mutually exclusive configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
release
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.