chore: Add git-cliff and git-sumi configrations

This commit is contained in:
Awiteb 2024-03-15 06:02:18 +03:00
parent fa42826085
commit 2aae3d35f9
Signed by: awiteb
GPG key ID: 3F6B55640AA6682F
2 changed files with 157 additions and 0 deletions

100
cliff.toml Normal file
View file

@ -0,0 +1,100 @@
[changelog]
# changelog header
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
"""
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, only one line #}\
{% macro bc_des(commit) %}\
{% for line in commit.message | split(pat="\n") %}\
{% if line is starting_with("BREAKING-CHANGE") %}\
{{line | split(pat=":") | nth(n=1) | split(pat="\n") | nth(n=0)}}\
{% endif %}\
{% endfor %}\
{% endmacro bc_des %}\
{% 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 | upper_first }}
{% for commit in commits | sort(attribute="message") %}\
- {{ self::commit_header(commit=commit) }} ([`{{ commit.id | truncate(length=7, end="") }}`](<REPO>/commit/{{ commit.id }}))
{% if self::is_breaking(commit=commit) == "true" %}\
\t- **BC**: {{self::bc_des(commit=commit)}}
{% endif %}\
{% endfor %}\
{% endfor %}\n
"""
# remove the leading and trailing whitespace from the template
trim = true
# changelog footer
footer = """
This changelog was generated by [git-cliff](https://github.com/orhun/git-cliff)
"""
# postprocessors
postprocessors = [
{pattern = '<REPO>', replace = "https://git.4rs.nl/awiteb/lprs"}, # replace repository URL
{pattern = '- \((\w+)\):', replace = "- (**$1**)"}, # Make the scope blod
{pattern = "\t", replace = " "}, # Replace tap with 4 spaces
]
[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}**](<REPO>/issues/${2}))"}, # replace issue numbers (Note the PR is also an issue in GitHub, 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 = [
# Gitmoji
{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 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
# 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"

57
sumi.toml Normal file
View file

@ -0,0 +1,57 @@
# git-sumi ~ configuration file
# Config: https://sumi.rs/docs/configuration
# Rules: https://sumi.rs/docs/rules
# Suppresses progress messages.
quiet = false
# Displays parsed commit message.
display = true
# Sets display format: cli, json, table, toml.
format = "cli"
# Processes each non-empty line as an individual commit.
split_lines = false
# Rule: Include one valid Gitmoji.
# See https://gitmoji.dev/.
gitmoji = false
# Rule: Description must start with the specified case.
# Options: 'any', 'lower', 'upper'.
description_case = "any"
# Rule: Use the imperative mood in the description.
# Example: 'Fix bug' instead of 'Fixed bug'.
imperative = true
# Rule: Do not end commit header with a period.
no_period = true
# Rule: Header length limit.
# A value of 0 disables the rule.
max_header_length = 55
# Rule: Body line length limit.
# A value of 0 disables the rule.
max_body_length = 80
# Rule: No leading, trailing, or consecutive spaces.
whitespace = true
# Rule: Follow Conventional Commits format.
# See https://www.conventionalcommits.org/.
conventional = true
# Rule: List of allowed commit scopes.
# An empty list allows all scopes. Example: ["docs", "cli"].
scopes_allowed = []
# Rule: List of allowed commit types.
# An empty list allows all types. Example: ["feat", "fix", "docs"].
types_allowed = ["feat", "fix", "docs", "refactor", "change", "deprecate", "remove", "security", "perf", "test", "chore"]
# Rule: Header must match regex pattern.
# Example: '^JIRA-\d+:'.
header_pattern = '^\w+(\s\(\w+\))?(!)?: \w'