PHP Classes

PHP Show Git Log of Changes: Generate a changelog from a local Git repository

Recommend this page to a friend!
  Info   View files Documentation   View files View files (17)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 30 This week: 1All time: 11,034 This week: 571Up
Version License PHP version Categories
gitchangelog 1.0.0Custom (specified...7.3Tools, PHP 7
Description 

Author

This package can generate a changelog from a local Git repository.

It can scan the log of commits of a Git repository in the current directory or a given path and extracts the record of changes.

The package can render the log of changes in several formats like HTML or Markdown.

Picture of DigiLive
  Performance   Level  
Name: DigiLive <contact>
Classes: 2 packages by
Country: The Netherlands The Netherlands
Age: 45
All time rank: 4412102 in The Netherlands The Netherlands
Week rank: 420 Up10 in The Netherlands The Netherlands Up
Innovation award
Innovation award
Nominee: 1x

Documentation

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. With 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/release.
  • List commit hashes per unique title (optional).
  • Include commit titles (and hashes) of the HEAD revision (E.g. Unreleased changes).
  • Append other content (E.g. An already existing changelog).
  • Save the content of the (appended) changelog to file.

Other

  • Set path to generate a changelog of another local repository.
  • Set a tag range to limit the changelog.
  • Filter titles by labels<sup>1</sup>.
  • Set a 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/releases<sup>2</sup>.
  • 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 commit view of the remote repository.
  • Format issues into links to Issue tracker of the repository.

Html Renderer

  • Format hashes into links to commit view of the remote repository.
  • Format issues into links to Issue tracker of the repository.

Installation

The preferred method is to install the library with Composer.

> composer require digilive/git-changelog:^1

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 save the changelog with all defaults.
$changelog->build();
$changelog->save('CHANGELOG.md');

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.

  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (2 files, 1 directory)
Files folder imagetests (5 files)
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files  /  .github  
File Role Description
Files folder imageISSUE_TEMPLATE (2 files)

  Files folder image Files  /  .github  /  ISSUE_TEMPLATE  
File Role Description
  Accessible without login Plain text file bug_report.md Data Auxiliary data
  Accessible without login Plain text file feature_request.md Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageRenderers (3 files)
  Plain text file GitChangelog.php Class Class source
  Plain text file Utilities.php Class Class source

  Files folder image Files  /  src  /  Renderers  
File Role Description
  Plain text file Html.php Class Class source
  Plain text file MarkDown.php Class Class source
  Plain text file RendererInterface.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script
  Plain text file GitChangelogTest.php Class Class source
  Plain text file HtmlTest.php Class Class source
  Plain text file MarkDownTest.php Class Class source
  Plain text file UtilitiesTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:30
This week:1
All time:11,034
This week:571Up