← All Exercises

Build a Changelog from Commit Messages

basicjavascript~20min

Background

Release notes assembled manually drift from history. Deriving them from commit types keeps consumers informed and makes breaking changes impossible to forget.

Problem

Group commit messages by type into ordered changelog sections and collect breaking changes into their own list.

Input

JSON object: { commits: [{ type, scope?, subject, breaking? }] }

Output

JSON object: { sections: [{ type, entries }], breaking: string[] }

Sample tests

Sample 1

Input: {"commits":[{"type":"fix","scope":"api","subject":"handle empty body"},{"type":"feat","subject":"add webhooks"},{"type":"feat","scope":"api","subject":"rename tenant header","breaking":true}]}
Expected: {"sections":[{"type":"feat","entries":["add webhooks","api: rename tenant header"]},{"type":"fix","entries":["api: handle empty body"]}],"breaking":["rename tenant header"]}

Sample 2

Input: {"commits":[{"type":"chore","subject":"bump dev deps"}]}
Expected: {"sections":[{"type":"chore","entries":["bump dev deps"]}],"breaking":[]}

Your solution

Learning objective

Produce release notes directly from commit metadata.