Skip to content

Commit f6ccf98

Browse files
committed
feat: add git template and cliff config for eficient change trakcing
This change should provide a way to partially enforce cleaner commits.
1 parent f02e654 commit f6ccf98

2 files changed

Lines changed: 87 additions & 0 deletions

File tree

.gitmessage

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# <type>: <short imperative summary, no period, aim for <=72 chars>
2+
#
3+
# < - why is this change needed? what does it do? — wrap at ~72 chars >
4+
# <reference issues if any, e.g. "Closes #42">
5+
#
6+
# ── Allowed types (these drive the changelog grouping) ───────────
7+
# feat a new feature -> Added
8+
# fix a bug fix -> Fixed
9+
# refactor code change, no behaviour change -> Changes
10+
# perf a performance improvement -> Changes
11+
# deps dependency add/update/remove -> Changes
12+
# docs documentation only -> Changes
13+
# chore tooling, config, housekeeping -> Changes
14+
# ci CI / workflow changes -> Changes
15+
# test a test for old or new behaviour -> Changes
16+
#
17+
# optional scope: feat(api): ... fix(db): ...
18+
# ─────────────────────────────────────────────────────────────────
19+
# Tips:
20+
# - Subject in the imperative: "Add X", not "Added X" / "Adds X".
21+
# - Keep the subject one line; put the detail in the body.
22+
# - The body's "why" is what makes the changelog write itself.

cliff.toml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# git-cliff configuration for spectra-gnoland-indexer
2+
# Tuned to the existing CHANGELOG.md style (Keep a Changelog + Added/Changes/Fixed).
3+
# Generate the next section with: git cliff --unreleased --tag v0.7.0
4+
# Regenerate the whole file with: git cliff -o CHANGELOG.md
5+
6+
[changelog]
7+
# Static header that matches the existing CHANGELOG.md preamble.
8+
header = """
9+
# Changelog
10+
11+
All notable changes to this project will be documented in this file.
12+
13+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
14+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
15+
"""
16+
17+
# How each release block is rendered.
18+
body = """
19+
{% if version %}\
20+
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
21+
{% else %}\
22+
## [Unreleased]
23+
{% endif %}\
24+
{% for group, commits in commits | group_by(attribute="group") %}
25+
### {{ group | striptags | trim | upper_first }}
26+
{% for commit in commits %}
27+
- {{ commit.message | upper_first }}\
28+
{% if commit.id %} [{{ commit.id | truncate(length=7, end="") }}](https://github.com/Cogwheel-Validator/spectra-gnoland-indexer/commit/{{ commit.id }}){% endif %}\
29+
{% endfor %}
30+
{% endfor %}\n
31+
"""
32+
trim = true
33+
34+
[git]
35+
# For now do not strictly follow Conventional Commits. After v1 this should be changed.
36+
conventional_commits = false
37+
filter_unconventional = false
38+
# Don't split a commit into multiple changelog entries.
39+
split_commits = false
40+
# Strip leading/trailing whitespace from messages.
41+
protect_breaking_commits = false
42+
43+
# Tidy up the subject line before it lands in the changelog:
44+
# drop the "prefix:" token (we re-group on it below) and the trailing period.
45+
commit_preprocessors = [
46+
{ pattern = '^\s*(?i)(add|added|feat|feature|change|changed|chore|deps|dep|refactor|refac|fix|bug|test|vuln|vulncheck|audit| ?fix|fixed|lint|go fmt|go fix|perf|docs|doc|test|ci|build)\s*:\s*', replace = "" },
47+
{ pattern = '\.\s*$', replace = "" },
48+
]
49+
50+
# Map each commit to a group by matching the ORIGINAL prefix.
51+
# The <!-- N --> markers control section ordering (git-cliff sorts groups by them).
52+
commit_parsers = [
53+
{ message = '^\s*(?i)(add|added|feat|feature)\s*:', group = "<!-- 0 -->Added" },
54+
{ message = '^\s*(?i)(fix|bug ?fix|fixed)\s*:', group = "<!-- 2 -->Fixed" },
55+
{ message = '^\s*(?i)(change|changed|chore|deps|dep|refactor|refac|lint|go fmt|go fix|perf|build|ci)\s*:', group = "<!-- 1 -->Changes" },
56+
{ message = '^\s*(?i)(test|audit|vulncheck|vuln)\s*:', group = "<!-- 3 -->Tests and Code Check" },
57+
# Anything without a recognised prefix lands here so nothing silently vanishes.
58+
# Triage these into the right section (or, better, start prefixing your commits).
59+
{ message = '.*', group = "<!-- 3 -->Uncategorized (please triage)" },
60+
]
61+
62+
# Process commits newest-first within each group.
63+
sort_commits = "newest"
64+
# Only include tags that look like releases.
65+
tag_pattern = "v[0-9]*"

0 commit comments

Comments
 (0)