From e1cf26e2a57266e786b395a76f0fc95a7b723cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sat, 19 Aug 2023 13:34:30 +0300 Subject: [PATCH] docs(example): add example for generating changelog similar to cocogitto --- examples/cocogitto.toml | 91 +++++++++++++++++++++++++ website/docs/templating/examples.md | 101 ++++++++++++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 examples/cocogitto.toml diff --git a/examples/cocogitto.toml b/examples/cocogitto.toml new file mode 100644 index 0000000000..b9674c3210 --- /dev/null +++ b/examples/cocogitto.toml @@ -0,0 +1,91 @@ +# configuration file for git-cliff + +[changelog] +# changelog header +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 +""" +# template for the changelog body +# https://tera.netlify.app/docs +body = """ +--- +{% if version %}\ + {% if previous.version %}\ + ## [{{ version | trim_start_matches(pat="v") }}]($REPO/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }} + {% else %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} + {% endif %}\ +{% else %}\ + ## [unreleased] +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | striptags | trim | upper_first }} + {% for commit in commits + | filter(attribute="scope") + | sort(attribute="scope") %} + - **({{commit.scope}})**{% if commit.breaking %} [**breaking**]{% endif %} \ + {{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }} + {%- endfor -%} + {% raw %}\n{% endraw %}\ + {%- for commit in commits %} + {%- if commit.scope -%} + {% else -%} + - {% if commit.breaking %} [**breaking**]{% endif %}\ + {{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }} + {% endif -%} + {% endfor -%} +{% endfor %}\n +""" +# remove the leading and trailing whitespace from the template +trim = true +# changelog footer +footer = """ + +""" +# postprocessors +postprocessors = [ + { pattern = '\$REPO', replace = "https://github.com/cocogitto/cocogitto" }, # replace repository URL +] + +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +# filter out the commits that are not conventional +filter_unconventional = true +# process each line of a commit as an individual commit +split_commits = false +# regex for preprocessing the commit messages +commit_preprocessors = [ + # { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/orhun/git-cliff/issues/${2}))"}, # replace issue numbers +] +# regex for parsing and grouping commits +commit_parsers = [ + { message = "^feat", group = "Features" }, + { message = "^fix", group = "Bug Fixes" }, + { message = "^doc", group = "Documentation" }, + { message = "^perf", group = "Performance" }, + { message = "^refactor", group = "Refactoring" }, + { message = "^style", group = "Style" }, + { message = "^revert", group = "Revert" }, + { message = "^test", group = "Tests" }, + { message = "^chore\\(version\\):", skip = true }, + { message = "^chore", group = "Miscellaneous Chores" }, + { body = ".*security", group = "Security" }, +] +# protect breaking changes from being skipped due to matching a skipping commit_parser +protect_breaking_commits = false +# filter out the commits that are not matched by commit parsers +filter_commits = false +# glob pattern for matching git tags +tag_pattern = "v[0-9]*" +# regex for skipping tags +skip_tags = "v0.1.0-beta.1" +# regex for ignoring tags +ignore_tags = "" +# sort the tags topologically +topo_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "oldest" +# limit the number of commits included in the changelog. +# limit_commits = 42 diff --git a/website/docs/templating/examples.md b/website/docs/templating/examples.md index 0948e78c91..8a6e43a675 100644 --- a/website/docs/templating/examples.md +++ b/website/docs/templating/examples.md @@ -810,3 +810,104 @@ All notable changes to this project will be documented in this file. + +#### [Cocogitto](https://github.com/orhun/git-cliff/tree/main/examples/cocogitto.toml) + +(similar to [cocogitto](https://github.com/cocogitto/cocogitto)'s [changelog](https://github.com/cocogitto/cocogitto/blob/main/CHANGELOG.md)) + +
+ Raw Output + +``` +# Changelog + +All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines. + +--- +## [unreleased] + +### Features + +- **(cache)** use cache while fetching pages - ([df6aef4](https://github.com/cocogitto/cocogitto/commit/df6aef41292f3ffe5887754232e6ea7831c50ba5)) - orhun +- **(config)** support multiple file formats - ([a9d4050](https://github.com/cocogitto/cocogitto/commit/a9d4050212a18f6b3bd76e2e41fbb9045d268b80)) - orhun + +--- +## [1.0.1](https://github.com/cocogitto/cocogitto/compare/v1.0.0..v1.0.1) - 2021-07-18 + +### Miscellaneous Chores + +- **(release)** add release script - ([06412ac](https://github.com/cocogitto/cocogitto/commit/06412ac1dd4071006c465dde6597a21d4367a158)) - orhun + +### Refactoring + +- **(parser)** expose string functions - ([e4fd3cf](https://github.com/cocogitto/cocogitto/commit/e4fd3cf8e2e6f49c0b57f66416e886c37cbb3715)) - orhun + +--- +## [1.0.0] - 2021-07-18 + +### Bug Fixes + +- **(args)** rename help argument due to conflict - ([9add0d4](https://github.com/cocogitto/cocogitto/commit/9add0d4616dc95a6ea8b01d5e4d233876b6e5e00)) - orhun + +### Documentation + +- **(example)** [**breaking**] add tested usage example - ([ad27b43](https://github.com/cocogitto/cocogitto/commit/ad27b43e8032671afb4809a1a3ecf12f45c60e0e)) - orhun +- **(project)** add README.md - ([81fbc63](https://github.com/cocogitto/cocogitto/commit/81fbc6365484abf0b4f4b05d384175763ad8db44)) - orhun + +### Features + +- **(parser)** add ability to parse arrays - ([a140cef](https://github.com/cocogitto/cocogitto/commit/a140cef0405e0bcbfb5de44ff59e091527d91b38)) - orhun + + +``` + +
+ +
+ Rendered Output + +# Changelog + +All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines. + +--- + +## [unreleased] + +### Features + +- **(cache)** use cache while fetching pages - ([df6aef4](https://github.com/cocogitto/cocogitto/commit/df6aef41292f3ffe5887754232e6ea7831c50ba5)) - orhun +- **(config)** support multiple file formats - ([a9d4050](https://github.com/cocogitto/cocogitto/commit/a9d4050212a18f6b3bd76e2e41fbb9045d268b80)) - orhun + +--- + +## [1.0.1](https://github.com/cocogitto/cocogitto/compare/v1.0.0..v1.0.1) - 2021-07-18 + +### Miscellaneous Chores + +- **(release)** add release script - ([06412ac](https://github.com/cocogitto/cocogitto/commit/06412ac1dd4071006c465dde6597a21d4367a158)) - orhun + +### Refactoring + +- **(parser)** expose string functions - ([e4fd3cf](https://github.com/cocogitto/cocogitto/commit/e4fd3cf8e2e6f49c0b57f66416e886c37cbb3715)) - orhun + +--- + +## [1.0.0] - 2021-07-18 + +### Bug Fixes + +- **(args)** rename help argument due to conflict - ([9add0d4](https://github.com/cocogitto/cocogitto/commit/9add0d4616dc95a6ea8b01d5e4d233876b6e5e00)) - orhun + +### Documentation + +- **(example)** [**breaking**] add tested usage example - ([ad27b43](https://github.com/cocogitto/cocogitto/commit/ad27b43e8032671afb4809a1a3ecf12f45c60e0e)) - orhun +- **(project)** add README.md - ([81fbc63](https://github.com/cocogitto/cocogitto/commit/81fbc6365484abf0b4f4b05d384175763ad8db44)) - orhun + +### Features + +- **(parser)** add ability to parse arrays - ([a140cef](https://github.com/cocogitto/cocogitto/commit/a140cef0405e0bcbfb5de44ff59e091527d91b38)) - orhun + + + +