Skip to content

Generate a changelog from git commits of the local repository

License

Notifications You must be signed in to change notification settings

DigiLive/gitChangelog

Repository files navigation

gitChangelog

GitHub release License Codacy Badge

Generate a changelog from git commits of the local repository.

This library parses information which is stored in a Git repository. From this information, it generates a changelog which can be saved to a file. The information is extracted from the branch which is currently checked out.

Take a look at this example. It is the changelog of the GitChangelog repository, build by this library.

If you have any questions, comments or ideas concerning this library, Please consult the Wiki at first. Create a new issue if your concerns remain unanswered.

Features

Main

  • Markdown and Html renderers included.

  • Choose included renderers or create your own.

  • List Tags and their date.

  • List unique commit titles per tag.

  • List commit hashes per unique title (optional).

  • Include commit titles (and hashes) of the HEAD revision (E.g. Unreleased changes).

Other

  • Use another local repository as information source.
  • Set a tag range to limit the changelog.
  • Filter titles by labels1.
  • Set a custom title for the changelog (E.g. a header).
  • Set a custom title for the HEAD revision (E.g. Next release version).
  • Set a custom date for the HEAD revision (E.g. Next release date).
  • Set a custom message to indicate there are no commits present.
  • In- or exclude merge commits.
  • Set an ordering key for sorting tags/releases2.
  • Set the sort order of tags/releases.
  • Set the sort order of titles.
  1. A label is considered to be the first word of a commit title.

  2. Using an invalid key will result in unlisted changes or when enabled, just the changes of the HEAD revision.

Markdown Renderer

  • Define a custom format for Tag/Release lines.

  • Define a custom format for title lines.

  • Format hashes into links to the commit-view of the remote repository provider.

  • Format issues into links to issue-tracker of the remote repository provider.

  • Format issues into links to merge-request (aka pull-request) view of the remote repository provider.

Html Renderer

  • Format hashes into links to the commit-view of the remote repository provider.

  • Format issues into links to issue-tracker of the remote repository provider.

  • Format issues into links to merge-request (aka pull-request) view of the remote repository provider.

Installation

The preferred method is to install the library with Composer.

> composer require digilive/git-changelog:^2

Set the version constraint to a value which suits you best.
Alternatively you can download the latest release from GitHub.

Minimal Example use

<?php

use DigiLive\GitChangelog\Renderers\MarkDown;
 
// Use composer's auto loader.
$requiredFile = 'Path/To/vendor/autoload.php';

// Or include the library manually.
// $requiredFile = 'Path/To/MarkDown.php';

require_once $requiredFile;

// Instantiate the library's renderer.
$changelog = new MarkDown();
// Build and get the changelog with all options set to default.
$changelog->build();
$content = $changelog->get();

Notes

  • Some options can be changed directly by setting a public property. (Setting a value of an invalid type, might result in unexpected results.)

  • Others have to be set by calling a method.

Commit guidelines

In order to create a good changelog, you should follow the following guidelines:

  • Commit messages must have a title line and may have body copy. These must be separated by a blank line.

  • The title line must not exceed 50 characters.

  • The title line should be capitalized and must not end in a period.

  • The title line must be written in an imperative mood (Fix, not Fixed / Fixes etc.).

  • The body copy must be wrapped at 72 columns.

  • The body copy must only contain explanations as to what and why, never how. The latter belongs in documentation and implementation.

About

Generate a changelog from git commits of the local repository

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages