Giter Site home page Giter Site logo

tomasbjerre / git-changelog-lib Goto Github PK

View Code? Open in Web Editor NEW
193.0 8.0 90.0 4.51 MB

Generate changelog, and/or next version, with, or without, conventional commits from a GIT repository

License: Apache License 2.0

Java 95.42% Mustache 4.58%
changelog release-automation conventional-changelog conventional-commits semantic-versioning

git-changelog-lib's Introduction

Git Changelog Lib

Maven Central

This is a library that can:

  • Generate a changelog, or releasenotes, from a GIT repository.
  • Determine next version, based on format of commits since last release.

It is fully configurable with a Mustache (Handlebars) template filled with a context of placeholders and helpers.

The changelog can:

  • Be stored to file, like CHANGELOG.md. There are some templates used for testing available here.
  • Or, just rendered to a String.

It can integrate with Jira, Redmine, GitLab and/or GitHub to retrieve the title of issues.

Usage

This software can be used:

There are examples of different templates in the code that are used for testing.

Template - Simple

Here is an example template.

# Changelog

Changelog for {{ownerName}} {{repoName}}.

{{#tags}}
## {{name}}
 {{#issues}}
  {{#hasIssue}}
   {{#hasLink}}
### {{name}} [{{issue}}]({{link}}) {{title}} {{#hasIssueType}} *{{issueType}}* {{/hasIssueType}} {{#hasLabels}} {{#labels}} *{{.}}* {{/labels}} {{/hasLabels}}
   {{/hasLink}}
   {{^hasLink}}
### {{name}} {{issue}} {{title}} {{#hasIssueType}} *{{issueType}}* {{/hasIssueType}} {{#hasLabels}} {{#labels}} *{{.}}* {{/labels}} {{/hasLabels}}
   {{/hasLink}}
  {{/hasIssue}}
  {{^hasIssue}}
### {{name}}
  {{/hasIssue}}

  {{#commits}}
**{{{messageTitle}}}**

{{#messageBodyItems}}
 * {{.}}
{{/messageBodyItems}}

[{{hash}}](https://github.com/{{ownerName}}/{{repoName}}/commit/{{hash}}) {{authorName}} *{{commitTime}}*

  {{/commits}}

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

Template - Conventional

If you are using conventional commits:

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

You can use built in helpers to produce a nice changelog. You can add your own helpers (using Javascript or Java) as described here.

{{#tags}}
{{#ifReleaseTag .}}
## [{{name}}](https://gitlab.com/html-validate/html-validate/compare/{{name}}) ({{tagDate .}})

  {{#ifContainsBreaking commits}}
    ### Breaking changes

    {{#commits}}
      {{#ifCommitBreaking .}}
  - {{#eachCommitScope .}} **{{.}}** {{/eachCommitScope}} {{{commitDescription .}}} ([{{hash}}](https://github.com/{{ownerName}}/{{repoName}}/commit/{{hash}}))
      {{/ifCommitBreaking}}
    {{/commits}}
  {{/ifContainsBreaking}}


  {{#ifContainsType commits type='feat'}}
    ### Features

    {{#commits}}
      {{#ifCommitType . type='feat'}}
  - {{#eachCommitScope .}} **{{.}}** {{/eachCommitScope}} {{{commitDescription .}}} ([{{hash}}](https://github.com/{{ownerName}}/{{repoName}}/commit/{{hash}}))
      {{/ifCommitType}}
    {{/commits}}
  {{/ifContainsType}}


  {{#ifContainsType commits type='fix'}}
    ### Bug Fixes

    {{#commits}}
      {{#ifCommitType . type='fix'}}
        - {{#eachCommitScope .}} **{{.}}** {{/eachCommitScope}} {{{commitDescription .}}} ([{{hash}}](https://github.com/{{ownerName}}/{{repoName}}/commit/{{hash}}))
      {{/ifCommitType}}
    {{/commits}}
  {{/ifContainsType}}

{{/ifReleaseTag}}
{{/tags}}

Partials

You can use partials in your templates.

changelog.hbs

{{#commits}}
{{> commit}}
{{/commits}}

commit.partial

## {{authorName}} - {{commitTime}}
[{{hashFull}}](https://server/{{hash}})
{{{message}}}

This is configured like:

gitChangelogApi
  .withTemplateBaseDir("...")
  .withTemplateSuffix(".partial"); //Optional, defaults to ".partial"

Helpers

Some helpers are implemented in this library. And users can also add more helpers as described in Handlebars. If you add your own helpers, using Javascript, you will need to add a scriptengine like Nashorn to your classpath.

ifReleaseTag <Tag>

Conditional, renders a block if given Tag matches release-tag.

{{#tags}}
 {{#ifReleaseTag .}}
  "{{.}}" is a release tag
 {{/ifReleaseTag}}
{{/tags}}

tagDate <Tag>

Renders date of Tag on format YYYY-MM-DD.

{{#tags}}
 {{tagDate .}}
{{/tags}}

ifContainsIssueType <List<Issue>>

Conditional, renders a block if given List<Issue> contains given type.

{{#ifContainsIssueType issues type="Bug"}}
  issues contains bugs
{{/ifContainsIssueType}}

ifContainsIssueTypeOtherThan <List<Issue>>

Conditional, renders a block if given List<Issue> contains issues that don't match the given type.

{{#ifContainsIssueTypeOtherThan issues type="fix"}}
  commits contains other types than fix
{{/ifContainsIssueTypeOtherThan}}

ifContainsIssueLabel <List<Issue>> label="<value>"

Conditional, renders a block if given List<Issue> contains given label.

{{#ifContainsIssueLabel issues label='enhancement'}}
  content here
{{/ifContainsIssueLabel}}

ifContainsIssueLabelOtherThan <List<Issue>>

Conditional, renders a block if given List<Issue> contains labels that don't match the given label.

{{#ifContainsIssueLabelOtherThan issues label='enhancement'}}
  content here
{{/ifContainsIssueLabel}}

ifIssueLabel <label> label="<value>"

Conditional, renders a block if given label matches the given value.

{{#ifIssueLabel . label='enhancement'}}
  Found a enhancement
{{/ifIssueLabel}}

ifContainsType <List<Commit>>

Conditional, renders a block if given List<Commits> contains given type.

{{#ifContainsType commits type="fix"}}
  commits contains fixes
{{/ifContainsType}}

ifContainsTypeOtherThan <List<Commit>>

Conditional, renders a block if given List<Commits> contains commits that don't match the given type.

{{#ifContainsTypeOtherThan commits type="fix"}}
  commits contains other types than fix
{{/ifContainsTypeOtherThan}}

ifContainsBreaking <List<Commit>>

Conditional, renders a block if given List<Commits> contains breaking changes.

{{#ifContainsBreaking commits}}
  commits contains fixes
{{/ifContainsBreaking}}

commitDate <Commit>

Renders date of Commit on format YYYY-MM-DD.

{{#commits}}
 {{commitDate .}}
{{/commits}}

commitDescription <Commit>

Renders description of Commit.

{{#commits}}
 {{commitDescription .}}
{{/commits}}

revertedCommit <Commit>

Renders reverted commit refered to by Commit.

{{#commits}}
 {{revertedCommit .}}
{{/commits}}

ifIssueType <Issue> type="<type>"

Conditional, renders a block if given Issue is of type.

{{#issues}}
 {{#ifIssueType . type="fix"}} is type fix {{/ifIssueType}}
{{/issues}}

ifIssueTypeOtherThan <Issue> type="<type>"

Conditional, renders a block if given Issue is of type.

{{#issues}}
 {{#ifIssueTypeOtherThan . type="fix"}} is not type fix {{/ifIssueTypeOtherThan}}
{{/issues}}

ifCommitType <Commit> type="<type>"

Conditional, renders a block if given Commit is of type.

{{#commits}}
 {{#ifCommitType . type="fix"}} is type fix {{/ifCommitType}}
{{/commits}}

ifCommitTypeOtherThan <Commit> type="<type>"

Conditional, renders a block if given Commit is of type.

{{#commits}}
 {{#ifCommitTypeOtherThan . type="fix"}} is not type fix {{/ifCommitTypeOtherThan}}
{{/commits}}

ifCommitBreaking <Commit>

Conditional, renders a block if given Commit is breaking.

{{#commits}}
 {{#ifCommitBreaking .}} is breaking {{/ifCommitBreaking}}
{{/commits}}

ifCommitScope <Commit> scope="utils"

Conditional, renders a block if given Commit has scope.

{{#commits}}
 {{#ifCommitScope . scope="utils"}} is scope utils {{/ifCommitScope}}
{{/commits}}

ifCommitHasFooters <Commit>

Conditional, renders a block if given Commit has footers.

{{#commits}}
 {{#ifCommitHasFooters .}} has footers {{/ifCommitHasFooters}}
{{/commits}}

ifCommitHasParagraphs <Commit>

Conditional, renders a block if given Commit has paragraphs.

{{#commits}}
 {{#ifCommitHasParagraphs .}} has paragraphs {{/ifCommitHasParagraphs}}
{{/commits}}

eachCommitScope <Commit>

Renders block for each scope in Commit.

{{#commits}}
 {{#eachCommitScope .}}
  scope: {{.}}
 {{/eachCommitScope}}
{{/commits}}

eachCommitRefs <Commit>

Renders block for each refs in Commit.

{{#commits}}
 {{#eachCommitRefs .}}
  references issue: {{.}}
 {{/eachCommitRefs}}
{{/commits}}

eachCommitFixes <Commit>

Renders block for each fixes in Commit.

{{#commits}}
 {{#eachCommitFixes .}}
  fixes issue: {{.}}
 {{/eachCommitFixes}}
{{/commits}}

eachCommitParagraph <Commit>

Renders block for each paragraph in Commit.

{{#commits}}
 {{#eachCommitParagraph .}}
  {{.}}
 {{/eachCommitParagraph}}
{{/commits}}

eachCommitFooter <Commit>

Renders block for each footer in Commit.

{{#commits}}
 {{#eachCommitFooter .}}
  {{token}}
 {{/eachCommitFooter}}
{{/commits}}

Optional tokenMatching regex parameter filters footer tokens.

ifFooterHasValue <Footer>

Conditional, renders a block if given Footer has value.

{{#commits}}
 {{#eachCommitFooter .}}
   {{#ifFooterHasValue .}}
    {{{value}}}
   {{/ifFooterHasValue}}
 {{/eachCommitFooter}}
{{/commits}}

ifEquals <a> <b>

Conditional, renders a block if a equals b.

{{#tags}}
 {{name}} Unreleased ? {{#ifEquals name "Unreleased"}} ja {{else}} nej {{/ifEquals}}
{{/tags}}

ifMatches <a> <b>

Conditional, renders a block if a matches regexp b.

{{#eachCommitFixes .}}
 {{#ifMatches . "^[A-Z]+-[0-9]+"}}
  fixes : "{{subString . 0 3}}" and number {{subString . 4}}
 {{/ifMatches}}
{{/eachCommitFixes}}

subString <a> <b> <c>

Works just like Java substring.

{{#eachCommitFixes .}}
 {{#ifMatches . "^[A-Z]+-[0-9]+"}}
  fixes : "{{subString . 0 3}}" and number {{subString . 4}}
 {{/ifMatches}}
{{/eachCommitFixes}}

Context

The template is supplied with this context of prepopulated mustache/handlebars variables:

Click here to show context

(ownerName, repoName, urlParts - derived from the clone URL, git remote origin MUST BE SET)
- ownerName (for this repo it would be "tomasbjerre")
- repoName (for this repo it would be "git-changelog-lib")
- urlParts (for this repo it would be [git-changelog-lib, tomasbjerre, [email protected]])
* commits
 - authorName
 - authorEmailAddress
 - commitTime
 - hash
 - hashFull
 - merge (True if this is a merge-commit)
 - message (The full message)
 - messageTitle (Only the first line of the message)
 - messageBody (Everything, except the title)
 * messageBodyItems (List of strings, the lines after the title)
* tags
 - name
 - annotation
 - tagTime
 - hasTagTime
 * commits
  - authorName
  - authorEmailAddress
  - commitTime
  - hash
  - hashFull
  - merge (True if this is a merge-commit)
  - message (The full message)
  - messageTitle (Only the first line of the message)
  - messageBody (Everything, except the title)
  * messageBodyItems (List of strings, the lines after the title)
 * authors
  - authorName
  - authorEmail
  * commits
   - authorName
   - authorEmailAddress
   - commitTime
   - hash
   - hashFull
   - merge (True if this is a merge-commit)
   - message (The full message)
   - messageTitle (Only the first line of the message)
   - messageBody (Everything, except the title)
   * messageBodyItems (List of strings, the lines after the title)
 * issueTypes
  - name (Like GitHub, GitLab, Jira, ...)
  * issues
   - name
   - hasIssue
   - issue
   - hasLink
   - link
   - hasTitle
   - title
   - hasDescription
   - description
   - hasType
   - type
   - isJira
   - isGitHub
   - isGitLab
   - isCustom
   - isNoIssue
   - hasLabels
   - labels
   - hasLinkedIssues
   - linkedIssues
   - hasAdditionalFields
   - additionalFields
   * commits
    - authorName
    - authorEmailAddress
    - commitTime
    - hash
    - hashFull
    - merge (True if this is a merge-commit)
    - message (The full message)
    - messageTitle (Only the first line of the message)
    - messageBody (Everything, except the title)
    * messageBodyItems (List of strings, the lines after the title)
   * authors
    - authorName
    - authorEmail
    * commits
     - authorName
     - authorEmailAddress
     - commitTime
     - hash
     - hashFull
     - merge (True if this is a merge-commit)
     - message (The full message)
     - messageTitle (Only the first line of the message)
     - messageBody (Everything, except the title)
     * messageBodyItems (List of strings, the lines after the title)
 * issues
  - name
  - hasIssue
  - issue
  - hasLink
  - link
  - hasTitle
  - title
  - hasDescription
  - description
  - hasType
  - type
  - isJira
  - isGitHub
  - isGitLab
  - isCustom
  - isNoIssue
  - hasLabels
  - labels
  - hasLinkedIssues
  - linkedIssues
  - hasAdditionalFields
  - additionalFields
  * commits
   - authorName
   - authorEmailAddress
   - commitTime
   - hash
   - hashFull
   - merge (True if this is a merge-commit)
   - message (The full message)
   - messageTitle (Only the first line of the message)
   - messageBody (Everything, except the title)
   * messageBodyItems (List of strings, the lines after the title)
  * authors
   - authorName
   - authorEmail
   * commits
    - authorName
    - authorEmailAddress
    - commitTime
    - hash
    - hashFull
    - merge (True if this is a merge-commit)
    - message (The full message)
    - messageTitle (Only the first line of the message)
    - messageBody (Everything, except the title)
    * messageBodyItems (List of strings, the lines after the title)
* authors
 - authorName
 - authorEmail
 * commits
  - authorName
  - authorEmailAddress
  - commitTime
  - hash
  - hashFull
  - merge (True if this is a merge-commit)
  - message (The full message)
  - messageTitle (Only the first line of the message)
  - messageBody (Everything, except the title)
  * messageBodyItems (List of strings, the lines after the title)
* issues
 - name
 - hasIssue
 - issue
 - hasLink
 - link
 - hasTitle
 - title
 - hasDescription
 - description
 - hasType
 - type
 - isJira
 - isGitHub
 - isGitLab
 - isCustom
 - isNoIssue
 - hasLabels
 - labels
 - hasLinkedIssues
 - linkedIssues
 - hasAdditionalFields
 - additionalFields
 * commits
  - authorName
  - authorEmailAddress
  - commitTime
  - hash
  - hashFull
  - merge (True if this is a merge-commit)
  - message (The full message)
  - messageTitle (Only the first line of the message)
  - messageBody (Everything, except the title)
  * messageBodyItems (List of strings, the lines after the title)
 * authors
  - authorName
  - authorEmail
  * commits
   - authorName
   - authorEmailAddress
   - commitTime
   - hash
   - hashFull
   - merge (True if this is a merge-commit)
   - message (The full message)
   - messageTitle (Only the first line of the message)
   - messageBody (Everything, except the title)
   * messageBodyItems (List of strings, the lines after the title)

Library

It has a builder for creating the changelog.

  gitChangelogApiBuilder()
   .withFromCommit(ZERO_COMMIT)
   .withToRef("refs/heads/master")
   .withTemplatePath("changelog.mustache")
   .render();

It can be used to calculate next version number, based on commits:

def nextVersion = gitChangelogApiBuilder()
  .withSemanticMajorVersionPattern("^[Bb]reaking")
  .withSemanticMinorVersionPattern("[Ff]eature")
  .getNextSemanticVersion();

println "Next version:" + nextVersion.toString();
println " Major:" + nextVersion.getMajor();
println " Minor:" + nextVersion.getMinor();
println " Patch:" + nextVersion.getPatch();

Settings can be supplied with the build or from a JSON config (documented here).

git-changelog-lib's People

Contributors

adechoudens avatar chme avatar clockworkorange avatar dmitrymamchur avatar drhip avatar edeso avatar gab1one avatar gillyobeast avatar grandchild avatar jagedn avatar jcustenborder avatar maartendcrius avatar mattdibi avatar mslipets avatar nurgling avatar polter05 avatar reda-alaoui avatar spacecowboy avatar tomasbjerre avatar tthornton3-chwy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

git-changelog-lib's Issues

1.0

  • Integrate
    • With GIthub to get title of issue
    • WIth Jira to get title of issue
  • Test cases

Commits not pulled correctly when using pipeline and commit points

I am using the new 1.57 build. The settings in my pipeline was generated using the pipeline syntax. I do also have a subfolder which has my code, hence the cd Android command.

I am trying to create a change log using the pipeline feature but my file is coming back with incorrect or blank info depending on the commit points I use.

The important settings specifying the commit points are:
subDirectory: 'Android', useSubDirectory: true

fromReference: 'abf73bee6bc3aea0a7ae364dfde00a89973e1684', fromType: 'commit'
toReference: '5f881607a03fb96394dbac584cfa0cd77ecf187b', toType: 'commit'

The change log is blank. I included the git log in a .log file which was created by running the below command right after the change log was created.
sh '''cd Android
git log > git.log'''
git.log

Not, always, including merged in commits

In this scenario:

*       a3f3de2 2016-03-08  Polish (Phillip Webb)
*       644ae2c 2016-03-08  Merge branch '1.3.x' (Phillip Webb)
|\  
| *     5e722da 2016-03-08 (origin/1.3.x)  Polish (Phillip Webb)
* |     d7d2404 2016-03-08  Ensure that Tomcat does not report unstopped main thread when startup fails (Andy Wilkinson)
* |     cc2f6f4 2016-03-08  Merge branch '1.3.x' (Stephane Nicoll)

When creating log from d7d2404 to 644ae2c. It will not include 5e722da!

Jenkins Changelog Plugin: Gets changes from master branch only

I am looking to get the changes from develop branch. I have specified the plugin to use develop branch but doesnt seem to obey it.

My environment:
Jenkins version 2.32.3
git version 2.8.2.windows.1

Jenkins changelog configuration:
image

Jenkins GIT configuration:
image

Dynamic Augmentation of Mustache Context

This is more of a feature request than an issue. I think it would be swell if the user could provide a hunk of JSON that could be added somewhere in the mustache context for later use in the template. This would allow for user lambdas for dynamic filtering and other general extension when creating the change logs.

For example, using the command line interface, one might:
git-changelog-lib --repo "\my\repo" --from-commit cec9173674a57866f87506e87cfb1e49a435f2c3 --to-ref HEAD --user-context-file context.json --output-file test.txt

With context.json having:
{ foo: 'bar'}

And a mustache template referencing it:

{{#usercontext}}{{!This would be an implicit object where the contents of the user context would be placed by git-changelog-lib}} We have foo {{foo}}! {{/usercontext}}

Additionally, one-off variables could be passed in rather than having to require a separate file be provided:

git-changelog-lib --repo "\my\repo" --from-commit cec9173674a57866f87506e87cfb1e49a435f2c3 --to-ref HEAD --user-context-foo bar --output-file test.txt

My particular use case is wanting to include some information from my build in the change logs, specifically the release number, but it seems this could be useful for other purposes as well.

Thanks for any consideration.

don't use current branch log

pom.xml

<plugin>
		        <groupId>se.bjurr.gitchangelog</groupId>
		        <artifactId>git-changelog-maven-plugin</artifactId>
		        <version>1.50</version>
		        <executions>
		          <execution>
		            <id>GenerateGitChangelog</id>
		            <phase>generate-sources</phase>
		            <goals>
		              <goal>git-changelog</goal>
		            </goals>
		            <configuration>
		              <!-- A file on filesystem //-->
		              <file>CHANGELOG.md</file>
		
		              
		            </configuration>
		          </execution>
		        </executions>
		      </plugin>

it created CHANGELOG.md ,but the log is from master branch instead of current branch

Git Change log show only Merges or have Merge as its own Tag

I was hoping that it would be able to only show Merges to Master like you can do with the folowing git log command:

git log --dense --merges --simplify-merges --pretty=oneline --date-order --date=iso8601 {#tag}..HEAD

The merge summarises what the branch your merging back in to your master branch, makin the change log a lot denser and readable and quicker to use as a sort of in this release we had this changes.

Maybe even better is to just show the {merge} tag, that you can use then as a header and with sub tags for the commits as it is now.

Add mustache example how to link to github issue

This is github issue #45 at github..com//issues/45

When i add a commit message "#45: some commit text" then commit is linked to the issue:

Is it possible to use this in an a generated changelog?

the example https://github.com/tomasbjerre/git-changelog-lib/blob/master/changelog.mustache seems to be hardcoded-linked to Jira issues.

I would like to link to github-issues instead.

Here is an example where commit-messages are linked to issues: k3b/APhotoManager#21

How to filter a message body item?

Hello,
how can i filter a message body item?

e.g. from message

--- 8< --- 8< begin message --- 8< --- 8<
titel

detailed information

(cherry picked from commit ....

Conflicts:

export.cpp

--- 8< --- 8< end message --- 8< --- 8<

remove the following lines

  1. (cherry picked from commit ...
  2. a line start with comment char #

could you please provide a method ignoreMessageBodyItemsIfItemMatches similary to method ignoreCommitsIfMessageMatches?
I would like to create 2 changelogs

  1. for internal use with information about cherry pick and git comments e.g. conflict infos
  2. for external use without information about cherry pick and git comments

Therefore, I can not globally disable git commit info (cherry picked from ... and comments in commit messages.

I use git-changelog-lib with git-changelog-command-line Tool.

Thank you very much
FO

Did not find a GIT repo

Hello. Have some problem with changelog plugin. I have 5 repos in that path, plugin didn't find them
--- Git Changelog ---

gitchangelog.api.exceptions.GitChangelogRepositoryException: Did not find a GIT repo in C:\Program Files (x86)\Jenkins\jobs\qwerty\workspace\Dependencies
at se.bjurr.gitchangelog.internal.git.GitRepo.(GitRepo.java:69)
at se.bjurr.gitchangelog.api.GitChangelogApi.getChangelog(GitChangelogApi.java:73)
at se.bjurr.gitchangelog.api.GitChangelogApi.render(GitChangelogApi.java:97)
at org.jenkinsci.plugins.gitchangelog.perform.RemoteCallable.call(RemoteCallable.java:130)
at org.jenkinsci.plugins.gitchangelog.perform.RemoteCallable.call(RemoteCallable.java:29)
at hudson.FilePath.act(FilePath.java:1105)
at org.jenkinsci.plugins.gitchangelog.perform.GitChangelogPerformer.performerPerform(GitChangelogPerformer.java:29)
at org.jenkinsci.plugins.gitchangelog.GitChangelogRecorder.perform(GitChangelogRecorder.java:52)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
at hudson.model.Build$BuildExecution.post2(Build.java:185)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665)
at hudson.model.Run.execute(Run.java:1766)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)

How to sort commit messages?

Hello,

how can i sort commit messages depending on same tags in the commit message?

----8<----8< begin message format----8<----8<
[scope] [type] titel

detailed information

some text [component]
some text [customer]

----8<----8< end message format----8<----8<

with
[scope]= Modul A or Modul B etc.
[type]=new or change or fix or test or refactoring or test etc.
[component]=component A or component B etc.
[customer]=customer A or customer B etc.

I would like to generate a sorted changelog
a) with full infomration for internal use
b) with fewer information for external use

For filtering messages there is the regex Pattern within ignoreCommitsIfMessageMatches and maybe issue#53 (How to filter a message body item?)

But how can commit messages be sorted with adaptive possibilities in the name and sequence of scope, type, component and customer?
example - format
scope (level 1)
type (level 2)
component (level 3)
customer (level 2)

example - log output
scope Modul A - heading Modul A
type new - heading type new
component A - heading component A
message 1
message 2
component B - heading component B
message 3
change - heading type change
component C - heading component C
message 4
fix - heading type fix
component A - heading component A
message 5
message 6
component B - heading component B
message 7
heading customers
customer A - heading customer A
message 8
message 9
customer B - heading customer A
message 10
Modul B - heading Modul B
fix - heading type fix
component C - heading component C
message 10

I use git-changelog-lib with git-changelog-command-line Tool.

Thank you very much
FO

Commits can be listed multiple times

These settings and such are not really what I used (removed some things), but they should replicate the problem

Example commit

Fix for a BUG

This fixes a BUG, as well as another BUG.

Resulting changelog

# Changelog for X

## Next Release

### Bugs

* Fix for a BUG
* Fix for a BUG
* Fix for a BUG

Settings and Template used

{
 "ignoreCommitsIfMessageMatches": "^\\[maven-release-plugin\\].*|^\\[Gradle Release Plugin\\].*|^Merge.*",
 "readableTagName": "/([^/]+?)$",
 "dateFormat": "YYYY-MM-dd HH:mm:ss",
 "untaggedName": "Next release",
 "noIssueName": "Other changes",
 "timeZone": "UTC",
 "removeIssueFromMessage": "false",

  "customIssues": [
    { "name": "Bugs", "pattern": "BUG" }
  ]
}
# Changelog x

{{#tags}}

## {{name}}

  {{#issueTypes}}

### {{name}}

    {{#issues}}
      {{#hasIssue}}
        {{#hasLink}}
          {{#commits}}
* {{{messageTitle}}} 
          {{/commits}}
        {{/hasLink}}
        {{^hasLink}}
         {{#commits}}
* {{{messageTitle}}}
         {{/commits}}
        {{/hasLink}}
      {{/hasIssue}}
      {{^hasIssue}}
        {{#commits}}
* {{{messageTitle}}}
        {{/commits}}
      {{/hasIssue}}
    {{/issues}}
  {{/issueTypes}}
{{/tags}}

Github Pull Requests integration

Hi !
Our company would like to use your lib for generating changelogs.

After a small analysis of the different kind of issues this library is able to parse in the commit messages (JIRA, GITHUB, CUSTOM), but the only one which would garanty to fetch developed features are the automated messages generated by github when a pull request is merged : "Merge pull request #XXX". Since users could forget to write their commit messages in a certain fashion.

It's already possible to detect such messages with CustomIssues, however, at this point we would need to fetch the pull request title. So the solution would be to develop a new kind of "SettingsIssueType".

I'd be very glad to contribute to develop this feature. I read the code, and it seems quite easy to extend for that request.

So here is some question:

  • Would you like me to develop that feature ?
  • If yes, once the feature is developed, how much time would you need to release a new gradle plugin including this new version of the git-changelog-lib ? My choosen solution unfortunately depend on my deadlines

My alternative is to fork and re-release a plugin, since we don't have internal gradle plugin repo.

Let me know asap please, and big up for this great lib !

cheers

Displaying multiple tags per commit

Are we able to display multiple tags at the same commit? Right now it looks like if a commit has two tags, one of them is not displayed.

Version 1.32

Auto hash link not configurable

At the moment the generated documentation work quite nice. However it tries to create links on the commit hahes. And it does not derive it or is configurable (at least clearly).

For example it generates a commit based on the has as folows:
https://github.com/tomasbjerre/git-changelog-lib/commit/6f8c1fb96a908b1

But in my case it should be:
https://bitbucket.org/{owner of repo}/{name of repo}/commits/.

This could be dynamecly derived from the git url thats given:
[email protected]:{owner of repo}/{name of repo}.git (and yeah the commits part I guess should be configurable seeing github and bitbucket have a difrent method there.)

Error while trying to create the changelog file.

ERROR: Step ‘Git Changelog’ aborted due to exception:
java.lang.NoClassDefFoundError: Could not initialize class se.bjurr.gitchangelog.internal.settings.Settings
at se.bjurr.gitchangelog.api.GitChangelogApi.(GitChangelogApi.java:430)
at se.bjurr.gitchangelog.api.GitChangelogApi.gitChangelogApiBuilder(GitChangelogApi.java:57)
at org.jenkinsci.plugins.gitchangelog.perform.RemoteCallable.call(RemoteCallable.java:56)
at org.jenkinsci.plugins.gitchangelog.perform.RemoteCallable.call(RemoteCallable.java:29)
at hudson.FilePath.act(FilePath.java:1083)
at org.jenkinsci.plugins.gitchangelog.perform.GitChangelogPerformer.performerPerform(GitChangelogPerformer.java:40)
at org.jenkinsci.plugins.gitchangelog.GitChangelogRecorder.perform(GitChangelogRecorder.java:52)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
at hudson.model.Build$BuildExecution.post2(Build.java:186)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665)
at hudson.model.Run.execute(Run.java:1753)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:405)
Finished: FAILURE

Missing Pull Request Merges in Git Changelog

The "Git Changelog" Publish Action works great in listing commits in the Jenkins Build Summary. However, it fails to list any of the Pull Request merges. Please see screenshots below of Actual Github Commits and the Jenkins Summary Page missing all the PR merges.

github_commits

jenkins_changelog

Getting full hash from Commit object

Now length of hash is limited to 15 digits.
private static String toHash(String input) { return input.substring(0, 15); }
It would be hady to have ability to get full hash in addition to shortened or to have ability to change length of available hash.

For example for integration with git in TFS I need to have full hash value to have proper link to commit in TFS in changelog.

GitLab integration

It would be nice to integrate changelog with GitLab. The APIs and OAuth are not compatible with GitHub:

  • In GitHub the issue number is "number". In GitLab is "iid".
  • In GitHub the link to the issue is "html_url". In GitLab is "web_url".
  • The OAuth in GitHub is "Authorization: token ". In GitLab is "PRIVATE_TOKEN ".

I can send a PR if needed.

Annotated tags support

Is that possible to include the description and/or releases notes (using Gitlab) for annotated tags ?

Unexcepted exception in GitInit

I’m getting an exception at

git-changelog-lib/src/main/java/se/bjurr/gitchangelog/internal/git/GitRepo.java

 Did not find a GIT repo in /var/jenkins/workspace/EBP-Build-Test
java.lang.RuntimeException: Did not find a GIT repo in /var/jenkins/workspace/EBP-Build-Test
    at se.bjurr.gitchangelog.internal.git.GitRepo.<init>(GitRepo.java:69)
    at se.bjurr.gitchangelog.api.GitChangelogApi.getChangelog(GitChangelogApi.java:306)
    at se.bjurr.gitchangelog.api.GitChangelogApi.render(GitChangelogApi.java:320)
    at org.jenkinsci.plugins.gitchangelog.perform.GitChangelogPerformer.performerPerform(GitChangelogPerformer.java:107)
    at org.jenkinsci.plugins.gitchangelog.GitChangelogRecorder.perform(GitChangelogRecorder.java:27)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
    at hudson.model.Build$BuildExecution.post2(Build.java:185)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
    at hudson.model.Run.execute(Run.java:1763)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)

The path is correct, corresponds to the workspace path and the .git folder is present, so I was wondering why this exception is popping up. Any idea ?

Jenkins version : 1.6.50
Plugin version: 1.7
Git client plugin 1.19.5
Git plugin 2.4.2
System Debian.

public GitRepo(File repo) {
      try {
       File repoFile = new File(repo.getAbsolutePath());
       File gitRepoFile = new File(repo.getAbsolutePath() + "/.git");
       if (gitRepoFile.exists()) {
        repoFile = gitRepoFile;
       }
       FileRepositoryBuilder builder = new FileRepositoryBuilder()//
         .findGitDir(repoFile)//
         .readEnvironment();
       if (builder.getGitDir() == null) {
        throw new RuntimeException("Did not find a GIT repo in " + repo.getAbsolutePath());
       }
       this.repository = builder.build();
      } catch (IOException e) {
       throw propagate(e);
      }
    }

Any Idea ??

Ability to grab the url from the git config.

hello
I was wondering if its possible or if its already implemented to get the URL form the git config so i can easily have it useable across multiple repos. either through copy and paste or in a script that is applied.

thank you for your time.

Feature-request (or question): Issues by category

Not sure if this is currently possible, but I am trying to achieve a changelog with categories, where each category is an issue source (each category is a custom issue). For example, the result I want is along these lines:

# My changelog

Changelog of my project

## [Next release](url)

### GitHub

* An issue [#123](url) in commit [abc124]
* An issue [#124](url) in commit [abc125]
* An issue [#125](url) in commit [abc126]
* An issue [#126](url) in commit [abc127]
* An issue [#127](url) in commit [abc128]

### CustomIssue1

* A custom issue in commit[abc234]
* A custom issue in commit[abc235]

### Other changes

* ...
* ...

To achieve this, I think you need to add under tags an item such as IssueTypes, where each type then has a name and issues.

Alternatively, the concept of a category could be a completely independent thing which you specify manually.

What do you think? Is there an easier way to achieve this with the existing implementation?

changelog is generating incorrect order of commits/Issues

Here is the scenario:
in Develop I add commit a
Create Release Branch v1.0
add commit b in release Branch
add commit c in Develop Branch (for v1.2)
add commit d in release Brach
Finish Release tag with v.10
merge to master & develop

When I generate the gitChangelog in develop branch
it puts commit b,c,d in v1.0 Whereas commit c has not yet released.

When I do a release 1.2 ( which has commit c and no other commit)
it doesn't even show up in the changlog

The only way commit c can be seen in correct place is if i do
fromRef=1.0
toRef=1.2
i will see c listed under 1.2. Not otherwise

task gitChangelogTask(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
    filePath = "CHANGELOG.md";
    templateContent = new File('changelog.mustache').getText('UTF-8');
    customIssues = [
            [ "Added", "(?i)(added)\\s*(?i)(JIRA-\\d{1,6})(.*)", "https://mycompanyjira.com/browse/\${PATTERN_GROUP_2}", "\${PATTERN_GROUP_3}"],
            [ "Fixed", "(?i)(fixed)\\s*(?i)(JIRA-\\d{1,6})(.*)", "https://mycompanyjira.com/browse/\${PATTERN_GROUP_2}", "\${PATTERN_GROUP_3}"],
    ]
    jiraIssuePattern = '(?!)' // to skip jira issues for now.
    untaggedName = "Next Release";
    ignoreCommitsWithoutIssue = true;
}

Changelog between REF_MASTER and REF_MASTER should be empty

I'm running gradle version of this library and when automation runs gitChangelog with thisset fromRef=master I'm obtaining an Unreleased version of that commit when I was expecting obtaining an empty changelog, given master is a tag referring my last commit.

This is the changelog I use to get in this case:

Changelog of my service

Unreleased

Related issues:

Commits:

  • 424eee812e127dd John McCoy 2018-01-19 14:04:15
    Merge pull request #153 in TEST/test from ~JOHN.MCCOY/test:TEST-02to master

Crash when git repo has no master branch

Hello, I'm trying to add git-changelog to my project.
My project does not have a master branch. I use version branches.
I get this crash when I run it: https://gist.github.com/mezz/b7efe8e440acc82105486c72c9dc5158

This seems to requite a master branch:
https://github.com/tomasbjerre/git-changelog-lib/blob/master/src/main/java/se/bjurr/gitchangelog/internal/git/GitRepo.java#L314-L315

Here is my project: https://github.com/mezz/JustEnoughItems

I tried setting fromCommit to my first commit sha but it still crashes the same way.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.