Generating wiki markup changelog from Git

I've found it useful to create a changelog at the end of a sprint or project phase.
Drupal article - Generating wiki markup changelog from Git

I've found it useful to create a changelog at the end of a sprint or project phase. A nicely formatted log can prove to be a valuable project history resource outside of the technical land of git and the command line, so why not format your logs straight into Wiki markup?

Using the —pretty=format option and declaring your sprint start date with —after{} you can create a nice changelog using Wiki markup:

git log --after={2014-01-01} --pretty=format:"* [%h|https://stash.mystashrepo.com/project/commit/%H] _%s_ (%cr) <%an>" --reverse | grep -v Merge > changelog.txt

 

The --reverse option is outputting oldest commits at the top, omit this option if you want  latest commits first. The --since option may give  you more flexibility than a static date:

git log --since=2.weeks
 

You could commit the changelog.txt file itself to the repo if you want to get all meta. Or simply paste the contents of the file into Jira, Confluence or any other Wiki markup compatible software. You could also consider making it an alias, piping the output directly to your clipboard or take it further and automate your logs and PUT the markup data somewhere useful.

The above pretty format git log outputs a Wiki format that looks like this in Confluence:

Neat right?

Other format options are available to include whatever relevant info you want from the commits.

%H Commit Hash
%h Abbreviated commit hash
%T Tree hash
%t Abbreviated tree hash
%P Parent hashes
%p Abbreviated parent hashes
%an Author name
%ae Author email
%ad Author date
%ar Author date relative
%cn Committer name
%ce Committer email
%cd Committer date
%cr Committer date relative
%s Subject

 

There are endless options for dealing with the history of code commits and version control, making it more readable for non-technical people is certainly worth writing a custom git log format!

 


 

The Author

James Harvey

Chief Development Officer