From 45965d9e574e93670f5beeae189b25a0fa398b79 Mon Sep 17 00:00:00 2001 From: Awiteb Date: Thu, 14 Nov 2024 19:13:26 +0000 Subject: [PATCH] chore: Add cliff configurations Signed-off-by: Awiteb --- cliff.toml | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 cliff.toml diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 0000000..e7fc130 --- /dev/null +++ b/cliff.toml @@ -0,0 +1,110 @@ +[changelog] +body = """ +{# Check if there is a `BREAKING-CHANGE` footer in the message or not #}\ +{% macro is_breaking(commit) %}\ + {{"BREAKING-CHANGE" in commit.message}}\ +{% endmacro is_breaking %}\ + +{# Return the commit header #}\ +{% macro commit_header(commit) %}\ + {{commit.message | split(pat="\n") | nth(n=0) | upper_first }}\ +{% endmacro commit_header %}\ + +{# Return the `BREAKING-CHANGE` footer message #}\ +{% macro bc_des(commit) %}\ + {% set lines = [] %}\ + {% set found_breaking = false %}\ + {% for line in commit.message | split(pat="\n") %}\ + {% if found_breaking and line is not containing(":") %}\ + {% set_global lines = lines | concat(with=line) %}\ + {% elif found_breaking and line is containing(":") %}\ + {% set_global found_breaking = false %}\ + {% endif %}\ + {% if line is starting_with("BREAKING-CHANGE") %}\ + {% set_global found_breaking = true %}\ + {% set breaking_line = line | split(pat=":") | nth(n=1) %}\ + {% set_global lines = lines | concat(with=breaking_line) %}\ + {% endif %}\ + {% endfor %}\ + {% if lines | length != 0 %}\ + {{ lines | join(sep="\n") | trim_end(pat="\n") }}\ + {% endif %}\ +{% endmacro bc_des %}\ + +{% if version %}\ + {% if previous.version %}\ + ## [{{ version | trim_start_matches(pat="v") }}](/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 | upper_first }} + {% for commit in commits | sort(attribute="message") %}\ + - {{ self::commit_header(commit=commit) }} ([`{{ commit.id | truncate(length=7, end="") }}`](/commit/{{ commit.id }})) + {% if self::is_breaking(commit=commit) == "true" %}\ + \t- **BC**: {{self::bc_des(commit=commit)}} + {% endif %}\ + {% endfor %}\ +{% endfor %}\n +""" + +footer = """ +This changelog was generated by [git-cliff](https://github.com/orhun/git-cliff) +""" + +header = """ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n +""" +postprocessors = [ + {pattern = '', replace = "https://git.4rs.nl/awiteb/forgejo-guardian"}, + {pattern = '- (\w+)(\(\w+\))?:', replace = "- "}, # Remove the type + {pattern = '- \((\w+)\):', replace = "- (**$1**)"}, # Make the scope blod + {pattern = "\t", replace = " "}, +] + +# remove the leading and trailing whitespace from the template +trim = true + +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = false +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}**](/issues/${2}))"}, # replace issue numbers (Note the PR is also an issue in Forgejo, so this will also link to PRs) + {pattern = ' +$', replace = ""}, # Remove trailing whitespace. + {pattern = ' +', replace = " "}, # Replace multiple spaces with a single space. +] +# regex for parsing and grouping commits +commit_parsers = [ + {message = "^feat", group = "Added"}, + {message = "^fix", group = "Fixed"}, + {message = "^(refactor|change)", group = "Changed"}, + {message = "^deprecate", group = "Deprecated"}, + {message = "^remove", group = "Removed"}, + {message = "^security", group = "Security"}, +] +protect_breaking_commits = false +# filter out the commits that are not matched by commit parsers +filter_commits = false +# regex for matching git tags +tag_pattern = "v[0-9]+\\.[0-9]+\\.[0-9]+" + +# regex for skipping tags +skip_tags = "" +# regex for ignoring tags +ignore_tags = "v[0-9]+\\.[0-9]+\\.[0-9]+-(alpha|beta|rc)(\\.[0-9]+)?" +# sort the tags topologically +topo_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "oldest"