tomasbjerre / git-changelog-lib

Generate changelog, and/or next version, with, or without, conventional commits from a GIT repository
Apache License 2.0
199 stars 92 forks source link

Ignore merge commits #81

Open nfalco79 opened 4 years ago

nfalco79 commented 4 years ago

Our organisation have implemented a Jenkins pipeline library. This library perform a JIRA integration. We implement a check at build time to force commit message template to refer issues of type defect or story. All issue types (Epic and subtasks) other could not be referred by commit for specific reason.

So in general we have commit that respect a precise template but we are using bitbucket and to close a PR it propose:

I would to be able to exclude the merge commits to gather JIRA issues. If I use ignoreCommitsIfMessageMatches that start with Merged also PR merged with squash strategy are ignore. For our scrum merge commit are not important to determinate which issue are in a release. The merge commit information is already there so it should be possible performa simple filter.

The best thing would be able to pass a callable (this is possible also in jenkins pipeline) to filter on Commit fields. Otherwise I have to ignore gathered issues and filter commit to get issue using the issue pattern.

manticore-projects commented 2 years ago

Greetings.

Looking for the same thing, I came up with:


task gitChangelogTask(type: GitChangelogTask) {
    fromRepo = file("$projectDir")
    file = new File("${projectDir}/src/site/sphinx/changelog.rst")
    fromRef = "4.0";
    //toRef = "1.1";
    templateContent ="""
************************
Changelog
************************

{{#tags}}
Version {{name}}
=============================================================

 {{#issues}}

  {{#commits}}
   {{#ifMatches messageTitle "^(?!Merge).*"}}
  * **{{messageTitle}}** - {{authorName}}
   {{/ifMatches}}
  {{/commits}}

 {{/issues}}
{{/tags}}
"""
}

The ifMatches does the trick.