forked from orhun/git-cliff
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(changelog): fix missing commit fields in context (orhun#837)
* feat(commit): add `raw_message` to `Commit` * test(fixtures): add test generate all fields in conventional commits * test(fixtures): add test do not discard missing fields in conventional commits when reading from context * docs(website): add `raw_message` fields to `context.md`
- Loading branch information
Showing
12 changed files
with
353 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[changelog] | ||
# template for the changelog footer | ||
header = """ | ||
# Changelog\n | ||
All notable changes to this project will be documented in this file. | ||
""" | ||
# template for the changelog body | ||
# https://keats.github.io/tera/docs/#introduction | ||
body = """ | ||
{% for group, commits in commits | group_by(attribute="group") %} | ||
## {{ group | striptags | trim | upper_first }} | ||
{% for commit in commits %} | ||
{% if commit.scope %}*({{ commit.scope }})* {% endif %}\ | ||
{% if commit.breaking %}[**breaking**]: {{ commit.breaking_description }}{% endif %} | ||
{{ commit.message }}: {{ commit.body }}\ | ||
{% for footer in commit.footers %} | ||
- {{ footer.token }}{{ footer.separator }} {{ footer.value }}\ | ||
{% endfor %} | ||
{% endfor %}\ | ||
{% endfor %}\n | ||
""" | ||
# template for the changelog footer | ||
footer = """ | ||
<!-- generated by git-cliff --> | ||
""" | ||
|
||
[git] | ||
# parse the commits based on https://www.conventionalcommits.org | ||
conventional_commits = true | ||
# process each line of a commit as an individual commit | ||
split_commits = false | ||
commit_parsers = [ | ||
{ message = "^feat", group = "Features", default_scope = "app" }, | ||
{ message = "^fix" }, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
GIT_COMMITTER_DATE="2022-04-06 01:25:08" git commit --allow-empty -m "Initial commit" | ||
GIT_COMMITTER_DATE="2022-04-06 01:25:09" git commit --allow-empty -m \ | ||
"feat(web): feature 1, breaking change in footer | ||
Body feature 1 | ||
BREAKING CHANGE: breaking change description feature 1 | ||
Signed-off-by: user1 <user1@example.com> | ||
Reviewed-by: user2 | ||
" | ||
|
||
GIT_COMMITTER_DATE="2022-04-06 01:25:10" git commit --allow-empty -m \ | ||
"feat(web)!: feature 2, breaking chain in description | ||
Body feature 2 | ||
Signed-off-by: user3 <user3@example.com> | ||
" | ||
|
||
GIT_COMMITTER_DATE="2022-04-06 01:25:11" git commit --allow-empty -m \ | ||
"feat!: feature 3, use default scope = app | ||
Body feature 2 | ||
Signed-off-by: user3 <user3@example.com> | ||
" | ||
|
||
GIT_COMMITTER_DATE="2022-04-06 01:25:12" git commit --allow-empty -m \ | ||
"fix(scope): fix 1, use scope as group | ||
Body fix 1 | ||
Fix: #1 | ||
" | ||
|
||
GIT_COMMITTER_DATE="2022-04-06 01:25:13" git commit --allow-empty -m \ | ||
"fix(front-end): fix 2, no footer | ||
Body fix 2 | ||
" | ||
|
||
GIT_COMMITTER_DATE="2022-04-06 01:25:14" git commit --allow-empty -m \ | ||
"fix(front-end): fix 3 and 4, no body but footer | ||
Fix: #3 | ||
Fix: #4 | ||
" | ||
|
||
git tag v0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
## Features | ||
|
||
*(web)* [**breaking**]: breaking change description feature 1 | ||
feature 1, breaking change in footer: Body feature 1 | ||
- BREAKING CHANGE: breaking change description feature 1 | ||
- Signed-off-by: user1 <user1@example.com> | ||
- Reviewed-by: user2 | ||
|
||
*(web)* [**breaking**]: feature 2, breaking chain in description | ||
feature 2, breaking chain in description: Body feature 2 | ||
- Signed-off-by: user3 <user3@example.com> | ||
|
||
*(app)* [**breaking**]: feature 3, use default scope = app | ||
feature 3, use default scope = app: Body feature 2 | ||
- Signed-off-by: user3 <user3@example.com> | ||
|
||
## Fix | ||
|
||
*(scope)* | ||
fix 1, use scope as group: Body fix 1 | ||
- Fix: #1 | ||
|
||
*(front-end)* | ||
fix 2, no footer: Body fix 2 | ||
|
||
*(front-end)* | ||
fix 3 and 4, no body but footer: | ||
- Fix: #3 | ||
- Fix: #4 | ||
|
||
<!-- generated by git-cliff --> |
35 changes: 35 additions & 0 deletions
35
.github/fixtures/test-from-context-does-not-discard-fields/cliff.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[changelog] | ||
# template for the changelog footer | ||
header = """ | ||
# Changelog\n | ||
All notable changes to this project will be documented in this file. | ||
""" | ||
# template for the changelog body | ||
# https://keats.github.io/tera/docs/#introduction | ||
body = """ | ||
{% for group, commits in commits | group_by(attribute="group") %} | ||
## {{ group | striptags | trim | upper_first }} | ||
{% for commit in commits %} | ||
{% if commit.scope %}*({{ commit.scope }})* {% endif %}\ | ||
{% if commit.breaking %}[**breaking**]: {{ commit.breaking_description }}{% endif %} | ||
{{ commit.message }}: {{ commit.body }}\ | ||
{% for footer in commit.footers %} | ||
- {{ footer.token }}{{ footer.separator }} {{ footer.value }}\ | ||
{% endfor %} | ||
{% endfor %}\ | ||
{% endfor %}\n | ||
""" | ||
# template for the changelog footer | ||
footer = """ | ||
<!-- generated by git-cliff --> | ||
""" | ||
|
||
[git] | ||
# parse the commits based on https://www.conventionalcommits.org | ||
conventional_commits = true | ||
# process each line of a commit as an individual commit | ||
split_commits = false | ||
commit_parsers = [ | ||
{ message = "^feat", group = "Features", default_scope = "app" }, | ||
{ message = "^fix" }, | ||
] |
52 changes: 52 additions & 0 deletions
52
.github/fixtures/test-from-context-does-not-discard-fields/commit.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
GIT_COMMITTER_DATE="2022-04-06 01:25:08" git commit --allow-empty -m "Initial commit" | ||
GIT_COMMITTER_DATE="2022-04-06 01:25:09" git commit --allow-empty -m \ | ||
"feat(web): feature 1, breaking change in footer | ||
Body feature 1 | ||
BREAKING CHANGE: breaking change description feature 1 | ||
Signed-off-by: user1 <user1@example.com> | ||
Reviewed-by: user2 | ||
" | ||
|
||
GIT_COMMITTER_DATE="2022-04-06 01:25:10" git commit --allow-empty -m \ | ||
"feat(web)!: feature 2, breaking chain in description | ||
Body feature 2 | ||
Signed-off-by: user3 <user3@example.com> | ||
" | ||
|
||
GIT_COMMITTER_DATE="2022-04-06 01:25:11" git commit --allow-empty -m \ | ||
"feat!: feature 3, use default scope = app | ||
Body feature 2 | ||
Signed-off-by: user3 <user3@example.com> | ||
" | ||
|
||
GIT_COMMITTER_DATE="2022-04-06 01:25:12" git commit --allow-empty -m \ | ||
"fix(scope): fix 1, use scope as group | ||
Body fix 1 | ||
Fix: #1 | ||
" | ||
|
||
GIT_COMMITTER_DATE="2022-04-06 01:25:13" git commit --allow-empty -m \ | ||
"fix(front-end): fix 2, no footer | ||
Body fix 2 | ||
" | ||
|
||
GIT_COMMITTER_DATE="2022-04-06 01:25:14" git commit --allow-empty -m \ | ||
"fix(front-end): fix 3 and 4, no body but footer | ||
Fix: #3 | ||
Fix: #4 | ||
" | ||
|
||
git tag v0.1.0 |
1 change: 1 addition & 0 deletions
1
.github/fixtures/test-from-context-does-not-discard-fields/context.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"version":"v0.1.0","message":null,"commits":[{"id":"1f276e5b2263e7c1b5524ea245fbb4ff61330381","raw_message":"feat(web): feature 1, breaking change in footer\n\nBody feature 1\n\nBREAKING CHANGE: breaking change description feature 1\nSigned-off-by: user1 <user1@example.com>\nReviewed-by: user2","message":"feature 1, breaking change in footer","body":"Body feature 1","footers":[{"token":"BREAKING CHANGE","separator":":","value":"breaking change description feature 1","breaking":true},{"token":"Signed-off-by","separator":":","value":"user1 <user1@example.com>","breaking":false},{"token":"Reviewed-by","separator":":","value":"user2","breaking":false}],"group":"Features","breaking_description":"breaking change description feature 1","breaking":true,"scope":"web","links":[],"author":{"name":"github-actions[bot]","email":"github-actions[bot]@users.noreply.github.com","timestamp":1728820879},"committer":{"name":"github-actions[bot]","email":"github-actions[bot]@users.noreply.github.com","timestamp":1649175909},"conventional":true,"merge_commit":false,"extra":null,"github":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"gitlab":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"gitea":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"bitbucket":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false}},{"id":"221fe9a8a564ffd1a9eae5fdae7a9c29b08dac83","raw_message":"feat(web)!: feature 2, breaking chain in description\n\nBody feature 2\n\nSigned-off-by: user3 <user3@example.com>","message":"feature 2, breaking chain in description","body":"Body feature 2","footers":[{"token":"Signed-off-by","separator":":","value":"user3 <user3@example.com>","breaking":false}],"group":"Features","breaking_description":"feature 2, breaking chain in description","breaking":true,"scope":"web","links":[],"author":{"name":"github-actions[bot]","email":"github-actions[bot]@users.noreply.github.com","timestamp":1728820879},"committer":{"name":"github-actions[bot]","email":"github-actions[bot]@users.noreply.github.com","timestamp":1649175910},"conventional":true,"merge_commit":false,"extra":null,"github":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"gitlab":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"gitea":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"bitbucket":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false}},{"id":"2c21dc3af7d88301d9f9009b7f952e3900d3919b","raw_message":"feat!: feature 3, use default scope = app\n\nBody feature 2\n\nSigned-off-by: user3 <user3@example.com>","message":"feature 3, use default scope = app","body":"Body feature 2","footers":[{"token":"Signed-off-by","separator":":","value":"user3 <user3@example.com>","breaking":false}],"group":"Features","breaking_description":"feature 3, use default scope = app","breaking":true,"scope":"app","links":[],"author":{"name":"github-actions[bot]","email":"github-actions[bot]@users.noreply.github.com","timestamp":1728820879},"committer":{"name":"github-actions[bot]","email":"github-actions[bot]@users.noreply.github.com","timestamp":1649175911},"conventional":true,"merge_commit":false,"extra":null,"github":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"gitlab":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"gitea":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"bitbucket":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false}},{"id":"ae3a44176f1b7491219d6cff66c05e06e464dade","raw_message":"fix(scope): fix 1, use scope as group\n\nBody fix 1\n\nFix: #1","message":"fix 1, use scope as group","body":"Body fix 1","footers":[{"token":"Fix","separator":":","value":"#1","breaking":false}],"group":"fix","breaking_description":null,"breaking":false,"scope":"scope","links":[],"author":{"name":"github-actions[bot]","email":"github-actions[bot]@users.noreply.github.com","timestamp":1728820879},"committer":{"name":"github-actions[bot]","email":"github-actions[bot]@users.noreply.github.com","timestamp":1649175912},"conventional":true,"merge_commit":false,"extra":null,"github":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"gitlab":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"gitea":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"bitbucket":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false}},{"id":"a9ed3d05585d4ae14bb5149c37f68a91e26175d6","raw_message":"fix(front-end): fix 2, no footer\n\nBody fix 2","message":"fix 2, no footer","body":"Body fix 2","footers":[],"group":"fix","breaking_description":null,"breaking":false,"scope":"front-end","links":[],"author":{"name":"github-actions[bot]","email":"github-actions[bot]@users.noreply.github.com","timestamp":1728820879},"committer":{"name":"github-actions[bot]","email":"github-actions[bot]@users.noreply.github.com","timestamp":1649175913},"conventional":true,"merge_commit":false,"extra":null,"github":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"gitlab":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"gitea":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"bitbucket":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false}},{"id":"71b8c16222328604b7e8940f4fcd3c8b07554f08","raw_message":"fix(front-end): fix 3 and 4, no body but footer\n\nFix: #3\nFix: #4","message":"fix 3 and 4, no body but footer","body":null,"footers":[{"token":"Fix","separator":":","value":"#3","breaking":false},{"token":"Fix","separator":":","value":"#4","breaking":false}],"group":"fix","breaking_description":null,"breaking":false,"scope":"front-end","links":[],"author":{"name":"github-actions[bot]","email":"github-actions[bot]@users.noreply.github.com","timestamp":1728820879},"committer":{"name":"github-actions[bot]","email":"github-actions[bot]@users.noreply.github.com","timestamp":1649175914},"conventional":true,"merge_commit":false,"extra":null,"github":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"gitlab":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"gitea":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false},"bitbucket":{"username":null,"pr_title":null,"pr_number":null,"pr_labels":[],"is_first_time":false}}],"commit_id":"71b8c16222328604b7e8940f4fcd3c8b07554f08","timestamp":1649175914,"previous":{"version":null,"message":null,"commits":[],"commit_id":null,"timestamp":0,"previous":null,"repository":null,"extra":null,"github":{"contributors":[]},"gitlab":{"contributors":[]},"gitea":{"contributors":[]},"bitbucket":{"contributors":[]}},"repository":"/home/dqk/workspace/rust/contrib/issue-837/test-from-context-does-not-discard-fields","extra":null,"github":{"contributors":[]},"gitlab":{"contributors":[]},"gitea":{"contributors":[]},"bitbucket":{"contributors":[]}}] |
35 changes: 35 additions & 0 deletions
35
.github/fixtures/test-from-context-does-not-discard-fields/expected.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
## Features | ||
|
||
*(web)* [**breaking**]: breaking change description feature 1 | ||
feature 1, breaking change in footer: Body feature 1 | ||
- BREAKING CHANGE: breaking change description feature 1 | ||
- Signed-off-by: user1 <user1@example.com> | ||
- Reviewed-by: user2 | ||
|
||
*(web)* [**breaking**]: feature 2, breaking chain in description | ||
feature 2, breaking chain in description: Body feature 2 | ||
- Signed-off-by: user3 <user3@example.com> | ||
|
||
*(app)* [**breaking**]: feature 3, use default scope = app | ||
feature 3, use default scope = app: Body feature 2 | ||
- Signed-off-by: user3 <user3@example.com> | ||
|
||
## Fix | ||
|
||
*(scope)* | ||
fix 1, use scope as group: Body fix 1 | ||
- Fix: #1 | ||
|
||
*(front-end)* | ||
fix 2, no footer: Body fix 2 | ||
|
||
*(front-end)* | ||
fix 3 and 4, no body but footer: | ||
- Fix: #3 | ||
- Fix: #4 | ||
|
||
<!-- generated by git-cliff --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
Initialized empty Git repository in /tmp/tmp.6oNPOAnyCc/.git/ | ||
[main (root-commit) ee8f28d] Initial commit | ||
[main 6b565e6] feat(web): feature, breaking change in footer | ||
[main 381ec3b] feat(web)!: feature 2, breaking chain in description | ||
[main 0c79b49] feat!: feature 3, use default scope | ||
[main 4cae9b0] fix(scope): fix 1, use scope as group | ||
[main 5fc71a3] fix(front-end): fix 2, no footer | ||
|
||
---Run git-cliff--- | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
## Features | ||
|
||
- *(web)* | ||
|
||
Feature, breaking change in footer | ||
|
||
|
||
- BREAKING_CHANGE: breaking change description feature 1 | ||
|
||
- Signed-off-by: user1 <user1@example.com> | ||
|
||
- Reviewed-by: user2 | ||
|
||
|
||
- *(web)* [**breaking**]: feature 2, breaking chain in description | ||
|
||
Feature 2, breaking chain in description | ||
|
||
|
||
- Signed-off-by: user3 <user3@example.com> | ||
|
||
|
||
- *(app)* [**breaking**]: feature 3, use default scope | ||
|
||
Feature 3, use default scope | ||
|
||
|
||
- Signed-off-by: user3 <user3@example.com> | ||
|
||
|
||
|
||
## Fix | ||
|
||
- *(scope)* | ||
|
||
Fix 1, use scope as group | ||
|
||
|
||
- Fix: #1 | ||
|
||
|
||
- *(front-end)* | ||
|
||
Fix 2, no footer | ||
|
||
|
||
- Fix: #2 | ||
|
||
|
||
|
||
<!-- generated by git-cliff --> |
Oops, something went wrong.