Skip to content

Changelog generator for conventional commits written in C#.

License

Notifications You must be signed in to change notification settings

jitesoft/cc-gen-sharp

Repository files navigation

CC-GEN

A generator of changelog from conventional commits.

Work in progress

This program is a work in progress, some features works basically as intended, but more should be added and the code is quite messy. Use at your own risk!

Why?

There are a lot of changelog generators out there, the reason for this one is that the ones already existing either did not work with lightweight tags or required a lot of extra things installed to work.
The idea of cc-gen is to have a simple single binary which is easy to run and easy to modify both in form of code and the templates/configuration which is used to generate output.

How?

There are currently two commands, init and generate|gen.
The former creates a configuration file locally or globally which allows you to change the templates used to generate the changelogs.
The later will generate a changelog.

Init

The init command can be invoked with a --global flag, in which case it will create a .cc-gen file in your home directory with the default configuration.

Without the --global flag, the file will be created in the directory where the command was invoked.

The following configuration values are available:

Header - The header of the changelog, defaults to '# Change Log'
Footer - The footer of the changelog, defaults to ''
GroupBreakingChanges - If any breaking changes should have their own section in the changelog, defaults to true.
GroupBreakingHeader - Header for breaking changes, defautls to '## Breaking changes'
Type - Template for 'Types'
DefaultType - Type any non-matched commits will go under (commits following cc but not found in TypeMap)
TypeMap - A map of 'types' and their possible values in the commit messages
BreakingCommit - Template for breaking changes, only used if 'GroupBreakingChanges' is false
Commit - Template for commits

Default for 'Commit':
  * [ {{ commit.sha | string.slice1 0 6 }} ] {{ header }} ({{ commit.committer.name }}) {{ commit.committer.when }}  

Default for 'BreakingCommit' 
  * [ {{ commit.sha | string.slice1 0 6 }} ] **breaking** {{ header }} ({{ commit.committer.name }}) {{ commit.committer.when }}  

Will later fill this part with a bit more information on what is passed to the template engine, for now, check the 'Conventional.cs' class

gen | generate

The generate command will generate a full changelog by default. It will order each commit under a tag and its types.
The following options can be passed: --latest, --from <tag> --to <tag>

If --latest is used, cc-gen will print the changes between current tip and the last tag.
If --from is used, a changelog without tags (will change in later version) will be printed from the given tag til the --to tag or first commit.

With what?

The application makes use of LibGit2Sharp to work with the git log, Scriban to handle the templates and YamlDotNet for Yaml parsing.
The command line helper used is System.CommandLine and tests makes use of XUnit and NSubstitute

Examples!

For an example, check the tags for cc-gen at GitLab or GitHub.