Generate a new CHANGELOG.md section from git history. Follow these steps exactly, no extra commentary.
- Determine the commit range:
- If
$1is given, use range$1..HEAD. - Else run !
git describe --tags --abbrev=0to find the last tag.- If a tag exists, use range
<tag>..HEAD. - If no tag exists, use the last 20 commits (
-20, no range).
- If a tag exists, use range
- If
- Run
git logover that range with--no-merges --pretty=format:%sto get one commit subject per line. - Categorize each commit subject into one of: Features, Fixes, Refactors, Docs, Chores.
- Use conventional-commit prefixes when present:
feat-> Features,fix-> Fixes,refactor-> Refactors,docs-> Docs,chore/build/ci/test/style-> Chores. - If no prefix, infer the best-fit category from the message wording. Default to Chores if unclear.
- Strip any conventional-commit prefix (e.g.
feat:,fix(scope):) from the entry text.
- Use conventional-commit prefixes when present:
- Read the existing CHANGELOG.md at the project root (if it exists). If it does not exist, create it with a single
# Changelogheader line. - Build a new section:
- Heading:
## YYYY-MM-DDusing today's date. - One sub-heading per non-empty category, in this order: Features, Fixes, Refactors, Docs, Chores. Skip categories with no commits.
- Under each sub-heading, one terse bullet per commit, exact commit subject text (prefix stripped), no rewording, no editorializing, no extra explanation.
- Heading:
- Suggest a semver bump for the section heading: MAJOR if any commit subject contains a breaking-change marker (
!after type/scope, e.g.feat!:, or the word "BREAKING"), else MINOR if any commit is categorized Features, else PATCH. Append it to the heading, e.g.## YYYY-MM-DD (suggested: minor). - Prepend the new section to CHANGELOG.md, directly under the
# Changelogheader (existing content below stays unchanged). Write the file. - Output only the final list of category headings used, the count of commits filed under each, and the suggested bump. No other commentary.