Skip to content

TobseF/kochamer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Kochamer: A merge changelog.md Kotlin script

(Ko)tlin (cha)ngelog (Mer)ge script

This script collects all markdown based changelog files in a given folder and inserts them into an existing CHANGELOG.md. It's used for Git workflows with separated changelog entries to avoid merge conflicts. Each story/branch can provide its own mini-changelog. And before a release you can easily merge them together. In addition it supports public and private sections.

This script has no dependencies and doesn't need gradle or maven to run.

Problem

We maintain our changelog for our product in the git repository next to the code. Every branch is based on a user story with a corresponding log entry. The changelog is one big file with the newest entry in the first line, the CHANGELOG.md. Now whenever we merge different branches together, merge conflicts are almost inevitable. Even the CHANGELOG merge=union didn't help to resolve these conflicts automatically.

Solution

Provide for every story/branch a separate changelog file named by the Jira Task (e.g. S-4203.md). Merge branches easily without any conflicts on a changelog. Before tag and release of the master branch run the kochamer.kt script to:

  1. Read all changelog files in a given folder.
  2. Group them by public and private sections.
  3. Add missing task identifiers based on the filename.
  4. Generate a release title based on the current date.
  5. Insert the new changelog entry into the existing CHANGELOG.md.
  6. Delete all merged changelog files.

Installation

Just configure the scripts vals on top. To run it as Kotlin Script you can change the file extions to .kts and add the missing main() call. Alternatively download the latest script release.

Example

Consider three files in the folder \changelog and our existing CHANGELOG.md in the main dir:

  • CHANGELOG.md
# 2018.01 of 05.01.2018

## public:
* Added stardust to the login screen. [S-4101]
* Added cookie based auto login. [S-4100]
* ....
  • changelog/S-4201.md
public:
* We added a tin opener in the tools section, yeah!

private:
* Added an admin function to use the tin opener to view on private user data. 
  • changelog/S-4203.md
private: * Fixed the bug which allowed user with umlauts in their names to login without password. 
  • changelog/S-4207.md
public: * The chat now supports the unicorn emoji.
private: * Removed the middle-finger emoji. 

After running kochamer.kt the CHANGELOG.md will be:

# 2018.04 of 26.01.2018

## public:
* We added a tin opener in the tools section, year! [S-4201]
* The chat now supports the unicorn emoji. [S-4207]

## private:
* Added an admin function to use the tin opener to view on private user data. [S-4203]
* Fixed the bug which allowed user with umlauts in their names to login without password. [S-4203]
* Removed the middle-finger emoji. [S-4207]

# 2018.01 of 05.01.2018

## public:
* Added stardust to the login screen. [S-4101]
* Added cookie based auto login. [S-4100]
* ....

View the KochamerTest for details.

Alternatives

FAQ

  • How can I run 'Kochamer'?
    Run it from IntelliJ with right-click run/Kochamer.TK
  • Can I change the date formatter?
    Yes, see locale = Locale.GERMAN
  • Kochamer isn't a real Kotlin script, right?
    Yes, it is simple Kotlin code. You can change the file extension to .kts to run it as a script. But this way you don't have the option to debug or test the code.
    For a prebuilt script look for the releases.