Skip to content

Commit

Permalink
feat(changelog): make changelog.header a template (#698)
Browse files Browse the repository at this point in the history
* feat(changelog): make changelog.header a template (#697)

* refactor: clean up implementation

* docs: update the description of header field

---------

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
  • Loading branch information
Cyclonit and orhun authored Jun 17, 2024
1 parent 50c240c commit 9fc12bb
Show file tree
Hide file tree
Showing 46 changed files with 155 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/fixtures/new-fixture-template/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-bump-initial-tag-cli-arg/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-bump-initial-tag-default/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-bump-initial-tag/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-bump-version-keep-zerover/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-bump-version/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-bumped-version/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-commit-footers/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-commit-preprocessors/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-configure-from-cargo-toml/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[package.metadata.git-cliff.changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-custom-scope/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-custom-tag-pattern/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-date-order/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-footer-template/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
31 changes: 31 additions & 0 deletions .github/fixtures/test-header-template/cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[changelog]
# template for the changelog footer
header = """
# Changelog
{% for release in releases %}\
{% if release.version %}\
{% if release.previous.version %}\
<!--{{ release.previous.version }}..{{ release.version }}-->
{% endif %}\
{% else %}\
<!--{{ release.previous.version }}..HEAD-->
{% endif %}\
{% endfor %}\
"""
# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}]
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\n
"""
# remove the leading and trailing whitespace from the templates
trim = true
16 changes: 16 additions & 0 deletions .github/fixtures/test-header-template/commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e

GIT_COMMITTER_DATE="2021-01-23 01:23:45" git commit --allow-empty -m "feat: add feature 1"
GIT_COMMITTER_DATE="2021-01-23 01:23:45" git commit --allow-empty -m "feat: add feature 2"
git tag v0.1.0

GIT_COMMITTER_DATE="2021-01-23 01:23:46" git commit --allow-empty -m "fix: fix feature 1"
GIT_COMMITTER_DATE="2021-01-23 01:23:46" git commit --allow-empty -m "fix: fix feature 2"
git tag v0.2.0

GIT_COMMITTER_DATE="2021-01-23 01:23:47" git commit --allow-empty -m "feat: add footer"
git tag v3.0.0

GIT_COMMITTER_DATE="2021-01-23 01:23:47" git commit --allow-empty -m "test: footer"
GIT_COMMITTER_DATE="2021-01-23 01:23:47" git commit --allow-empty -m "perf: footer"
33 changes: 33 additions & 0 deletions .github/fixtures/test-header-template/expected.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Changelog
<!--v3.0.0..HEAD-->
<!--v0.2.0..v3.0.0-->
<!--v0.1.0..v0.2.0-->
## [unreleased]

### Perf

- Footer

### Test

- Footer

## [3.0.0]

### Feat

- Add footer

## [0.2.0]

### Fix

- Fix feature 1
- Fix feature 2

## [0.1.0]

### Feat

- Add feature 1
- Add feature 2
2 changes: 1 addition & 1 deletion .github/fixtures/test-ignore-tags/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-keep-a-changelog-links/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-latest-with-one-tag/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-limit-commits/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-no-exec/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-regex-replace-parser/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-skip-breaking-changes/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-skip-commits/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-split-commits/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-topo-order-arg/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion .github/fixtures/test-topo-order/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# See documentation for more information on available options.

[changelog]
# changelog header
# template for the changelog footer
header = """
[![animation](https://raw.githubusercontent.com/orhun/git-cliff/main/website/static/img/git-cliff-anim.gif)](https://git-cliff.org)\n
"""
Expand Down
2 changes: 1 addition & 1 deletion config/cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# See documentation for more information on available options.

[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion examples/cocogitto.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://git-cliff.org/docs/configuration

[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.\n
Expand Down
2 changes: 1 addition & 1 deletion examples/detailed.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://git-cliff.org/docs/configuration

[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion examples/github-keepachangelog.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://git-cliff.org/docs/configuration

[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.
Expand Down
2 changes: 1 addition & 1 deletion examples/keepachangelog.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://git-cliff.org/docs/configuration

[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.
Expand Down
2 changes: 1 addition & 1 deletion examples/scoped.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://git-cliff.org/docs/configuration

[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion examples/scopesorted.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://git-cliff.org/docs/configuration

[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
2 changes: 1 addition & 1 deletion examples/unconventional.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://git-cliff.org/docs/configuration

[changelog]
# changelog header
# template for the changelog footer
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Expand Down
Loading

0 comments on commit 9fc12bb

Please sign in to comment.