/git-changelog-lib

Library for parsing and generating a changelog, or releasenotes, from a GIT repository

Primary LanguageJavaApache License 2.0Apache-2.0

Git Changelog Lib Build Status Maven Central

This is a library for generating a changelog, or releasenotes, from a GIT repository. It can also be run as a standalone program, Gradle plugin, Maven plugin or Jenkins plugin.

It is fully configurable with a Mustache template. That can:

  • Be stored to file, like CHANGELOG.md. There are some templates used for testing available here and the results here.
  • Be posted to MediaWiki (here is an example)
  • Or just be printed to STDOUT

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

There are some screenshots here.

Usage

This software can be used:

Here is an example template. There are more examples here.

# Git Changelog changelog

Changelog of Git Changelog.
{{#tags}}
## {{name}}
 {{#issues}}
  {{#hasLink}}
### {{name}} [{{issue}}]({{link}}) {{title}}
  {{/hasLink}}
  {{^hasLink}}
### {{name}} {{title}}
  {{/hasLink}}
  {{#authors}}
* {{authorName}}
   {{#commits}}
[{{hash}}](https://server/{{hash}}) *{{commitTime}}*
{{{message}}}

   {{/commits}}

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

Settings can be supplied with a JSON config (documented here).

Library

It has a builder for creating the changelog.

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

It can also create releasenotes. If you are using git flow it may look like this.

  gitChangelogApiBuilder()
   .withFromRef("refs/heads/dev")
   .withToRef("refs/heads/master")
   .withTemplatePath("releasenotes.mustache")
   .toStdout();

A page can be created in MediaWiki like this.

 .toMediaWiki(
  "username",
  "password",
  "http://host/mediawiki",
  "Title of page");

Supplied information

The template is supplied with a datastructure like:

* commits
 - authorName
 - authorEmailAddress
 - message
 - commitTime
* tags
 - name
 * commits
  - authorName
  - authorEmailAddress
  - message
  - commitTime
 * authors
  - authorName
  - authrorEmail
  * commits
   - authorName
   - authorEmailAddress
   - message
   - commitTime
 * issues
  - name
  - hasIssue
  - issue
  - hasLink
  - link
  - hasTitle
  - title
  * commits
   - authorName
   - authorEmailAddress
   - message
   - commitTime
  * authors
   - authorName
   - authrorEmail
   * commits
    - authorName
    - authorEmailAddress
    - message
    - commitTime
* authors
 - authorName
 - authrorEmail
 * commits
  - authorName
  - authorEmailAddress
  - message
  - commitTime
* issues
 - name
 - hasIssue
 - issue
 - hasLink
 - link
 - hasTitle
 - title
 * commits
  - authorName
  - authorEmailAddress
  - message
  - commitTime
 * authors
  - authorName
  - authrorEmail
  * commits
   - authorName
   - authorEmailAddress
   - message
   - commitTime

MediaWiki

The library can create a wiki page in MediaWiki. To do this, you must enable the API in MediaWiki in mediawiki/LocalSettings.php by adding:

$wgEnableAPI = true;
$wgEnableWriteAPI = true;

Developer instructions

To build the code, have a look at .travis.yml.

To do a release you need to do ./gradlew release and release the artifact from staging. More information here.