Skip to content

Commit

Permalink
docs(example): add example for generating changelog similar to cocogitto
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Aug 19, 2023
1 parent 445ad2c commit e1cf26e
Show file tree
Hide file tree
Showing 2 changed files with 192 additions and 0 deletions.
91 changes: 91 additions & 0 deletions examples/cocogitto.toml
Original file line number Diff line number Diff line change
@@ -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 = """
<!-- generated by git-cliff -->
"""
# 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
101 changes: 101 additions & 0 deletions website/docs/templating/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -810,3 +810,104 @@ All notable changes to this project will be documented in this file.
<!-- generated by git-cliff -->

</details>

#### [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))

<details>
<summary>Raw Output</summary>

```
# 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
<!-- generated by git-cliff -->
```

</details>

<details>
<summary>Rendered Output</summary>

# 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

<!-- generated by git-cliff -->

</details>

0 comments on commit e1cf26e

Please sign in to comment.