Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conventional commit types should be case insensitive #444

Open
joshka opened this issue Jan 12, 2024 · 4 comments
Open

Conventional commit types should be case insensitive #444

joshka opened this issue Jan 12, 2024 · 4 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@joshka
Copy link
Contributor

joshka commented Jan 12, 2024

Describe the bug

I noticed a missing commit (using just the default config) that was due to the type being capitalized.

https://www.conventionalcommits.org/en/v1.0.0/#are-the-types-in-the-commit-title-uppercase-or-lowercase

Any casing may be used, but it’s best to be consistent.

To reproduce

Make a commit titled e.g. FEAT: this won't show up

Expected behavior

Commit type detection should ignore case as this is easy to overlook in a commit message.

Screenshots / Logs

Software information

  • Operating system:
  • Rust version:
  • Project version:

Additional context

@joshka joshka added the bug Something isn't working label Jan 12, 2024
@orhun
Copy link
Owner

orhun commented Jan 12, 2024

I am unable to reproduce this.

cd $(mktemp -d)
git init
git commit --allow-empty -m "feat: initial"
git commit --allow-empty -m "Feat: 2nd commit"
git commit --allow-empty -m "FEAT: this won't show up"
git commit --allow-empty -m "FeAt(something): TEST"
git cliff
# Changelog

All notable changes to this project will be documented in this file.

## [unreleased]

### FEAT

- This won't show up

### FeAt

- TEST

### Feat

- 2nd commit

### Features

- Initial

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

Maybe it is a release-plz bug? @MarcoIeni

@orhun orhun added the question Further information is requested label Jan 12, 2024
@joshka
Copy link
Contributor Author

joshka commented Jan 12, 2024

❯ git cliff --version
git-cliff 1.4.0
❯ git log
commit 9fcf4ffbb5ea9e44dad2724ee51f33b22bff6361 (HEAD)
Author: Josh McKinney <joshka@users.noreply.github.com>
Date:   Thu Jan 11 21:12:47 2024 -0800

    chore(readme): more cleanup

commit f127fde7e945310d77aed010fb2198eecd555dc5
Author: Josh McKinney <joshka@users.noreply.github.com>
Date:   Thu Jan 11 20:48:54 2024 -0800

    docs: improve examples

commit 70490cd39380dd06b175e37bf9be2555a1cb1872
Author: Josh McKinney <joshka@users.noreply.github.com>
Date:   Thu Jan 11 20:22:46 2024 -0800

    chore(readme): clean up links

commit 9ffb3bf11e5405ecb339752b52eeedf3897ed347
Author: p0kR <26470877+p0kR@users.noreply.github.com>
Date:   Fri Jan 12 05:08:33 2024 +0100

    Feat: add PixelSize option (#22)

    Add a new `TuiBigText::pixel_size()` option that indicates the size of a pixel in the font
    - Full: a full character cell (`'█'`)
    - HalfHeight: a half (upper/lower) character cell (`'▀', '▄'`)
    - HalfWidth: a half (left/right) character cell (`'▌', '▐'`)
    - Quadrant: a quadrant of a character cell (`'▘', '▝', '▖', '▗'`)

    The Half height option leads to the most square looking pixels as terminals usually render
    cells around twice as high as they are wide.

    ---------

    Co-authored-by: p0kR <572829-p0kR@users.noreply.gitlab.com>
    Co-authored-by: Josh McKinney <joshka@users.noreply.github.com>

commit a008e83a68dbe4dab6e225b53bc7d31e087b6cc8 (tag: v0.3.1, p0kR/main)
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Fri Dec 22 17:29:42 2023 -0800

    chore: release (#21)

    Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
❯ git cliff
# Changelog

All notable changes to this project will be documented in this file.

## [unreleased]

### Documentation

- [f127fde](https://github.com/joshka/tui-big-text/commit/f127fde7e945310d77aed010fb2198eecd555dc5)
  Improve examples

### Miscellaneous Tasks

- [70490cd](https://github.com/joshka/tui-big-text/commit/70490cd39380dd06b175e37bf9be2555a1cb1872)
  Clean up links
- [9fcf4ff](https://github.com/joshka/tui-big-text/commit/9fcf4ffbb5ea9e44dad2724ee51f33b22bff6361)
  More cleanup


## [0.3.1](https://github.com/joshka/tui-big-text/releases/tag/v0.3.1) - 2023-12-23

### Documentation

- [bc3cd46](https://github.com/joshka/tui-big-text/commit/bc3cd46a8f2e34ae65054b6191e9475d477612c1)
  Update example image (#20)


## [0.3.0](https://github.com/joshka/tui-big-text/releases/tag/v0.3.0) - 2023-12-23
...

Cliff.toml:

# git-cliff ~ default configuration file
# https://git-cliff.org/docs/configuration
#
# Lines starting with "#" are comments.
# Configuration options are organized into tables and keys.
# See documentation for more information on available options.

[changelog]
# changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file.
"""
# template for the changelog body
# https://tera.netlify.app/docs
body = """
{% set repo = "https://github.com/joshka/tui-big-text/" -%}
{%- if version %}
## [{{ version | trim_start_matches(pat="v") }}]({{ repo ~ "releases/tag/" ~ version }}) \
  - {{ timestamp | date(format="%Y-%m-%d") }}
{%- else %}
## [unreleased]
{%- endif %}
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- [{{ commit.id | truncate(length=7, end="") }}]({{ repo ~ "commit/" ~ commit.id }})
  {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\
  {%- if commit.body %}

  ````text {#- 4 backticks escape any backticks in body #}
  {{commit.body | indent(prefix="  ") }}
  ````
  {%- endif -%}
{% endfor %}
{% endfor %}
"""
# remove the leading and trailing whitespace from the template
trim = false
# changelog footer
footer = """
<!-- generated by git-cliff -->
"""
# postprocessors
postprocessors = [
  # { pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" }, # 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 = false
# 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
]
# regex for parsing and grouping commits
commit_parsers = [
  { message = "^feat", group = "Features" },
  { message = "^fix", group = "Bug Fixes" },
  { message = "^(doc|docs)", group = "Documentation" },
  { message = "^perf", group = "Performance" },
  { message = "^refactor", group = "Refactor" },
  { message = "^style", group = "Styling" },
  { message = "^test", group = "Testing" },
  { message = "^chore: release", skip = true },
  { message = "^chore\\(deps\\)", skip = true },
  { message = "^chore\\(pr\\)", skip = true },
  { message = "^chore\\(pull\\)", skip = true },
  { message = "^chore|ci", group = "Miscellaneous Tasks" },
  { body = ".*security", group = "Security" },
  { message = "^revert", group = "Revert" },
]
# 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 = true
# 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

Looks like my config is a little outdated. I think perhaps the filter_commits setting was the culprit. Diff from current default cliff.toml:

diff --git a/cliff.toml b/cliff.toml
index 5790a36..7beeaca 100644
--- a/cliff.toml
+++ b/cliff.toml
@@ -9,34 +9,25 @@
 # changelog header
 header = """
 # Changelog\n
-All notable changes to this project will be documented in this file.
+All notable changes to this project will be documented in this file.\n
 """
 # template for the changelog body
-# https://tera.netlify.app/docs
+# https://keats.github.io/tera/docs/#introduction
 body = """
-{% set repo = "https://github.com/joshka/tui-big-text/" -%}
-{%- if version %}
-## [{{ version | trim_start_matches(pat="v") }}]({{ repo ~ "releases/tag/" ~ version }}) \
-  - {{ timestamp | date(format="%Y-%m-%d") }}
-{%- else %}
-## [unreleased]
-{%- endif %}
+{% if version %}\
+    ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
+{% else %}\
+    ## [unreleased]
+{% endif %}\
 {% for group, commits in commits | group_by(attribute="group") %}
-### {{ group | upper_first }}
-{% for commit in commits %}
-- [{{ commit.id | truncate(length=7, end="") }}]({{ repo ~ "commit/" ~ commit.id }})
-  {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\
-  {%- if commit.body %}
-
-  ````text {#- 4 backticks escape any backticks in body #}
-  {{commit.body | indent(prefix="  ") }}
-  ````
-  {%- endif -%}
-{% endfor %}
-{% endfor %}
+    ### {{ group | upper_first }}
+    {% for commit in commits %}
+        - {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\
+    {% endfor %}
+{% endfor %}\n
 """
 # remove the leading and trailing whitespace from the template
-trim = false
+trim = true
 # changelog footer
 footer = """
 <!-- generated by git-cliff -->
@@ -49,7 +40,7 @@ postprocessors = [
 # parse the commits based on https://www.conventionalcommits.org
 conventional_commits = true
 # filter out the commits that are not conventional
-filter_unconventional = false
+filter_unconventional = true
 # process each line of a commit as an individual commit
 split_commits = false
 # regex for preprocessing the commit messages
@@ -60,12 +51,12 @@ commit_preprocessors = [
 commit_parsers = [
   { message = "^feat", group = "Features" },
   { message = "^fix", group = "Bug Fixes" },
-  { message = "^(doc|docs)", group = "Documentation" },
+  { message = "^doc", group = "Documentation" },
   { message = "^perf", group = "Performance" },
   { message = "^refactor", group = "Refactor" },
   { message = "^style", group = "Styling" },
   { message = "^test", group = "Testing" },
-  { message = "^chore: release", skip = true },
+  { message = "^chore\\(release\\): prepare for", skip = true },
   { message = "^chore\\(deps\\)", skip = true },
   { message = "^chore\\(pr\\)", skip = true },
   { message = "^chore\\(pull\\)", skip = true },
@@ -76,9 +67,10 @@ commit_parsers = [
 # 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 = true
-# glob pattern for matching git tags
-tag_pattern = "v[0-9]*"
+filter_commits = false
+# regex for matching git tags
+tag_pattern = "v[0-9].*"
+
 # regex for skipping tags
 skip_tags = "v0.1.0-beta.1"
 # regex for ignoring tags

With the default, I now see this:

❯ git cliff
# Changelog

All notable changes to this project will be documented in this file.

## [unreleased]

### Documentation

- Improve examples

### Feat

- Add PixelSize option (#22)

### Miscellaneous Tasks

- Clean up links
- More cleanup

Which at least doesn't filter out the Feat now, but that should still be a case insensitive match and end up under Features not Feat.

@orhun
Copy link
Owner

orhun commented Jan 15, 2024

Yeah, the issue is:

 commit_parsers = [
   { message = "^feat", group = "Features" },
]
filter_commits = true

You can do this instead:

 commit_parsers = [
   { message = "^[fF]eat", group = "Features" },
]
filter_commits = false

@joshka
Copy link
Contributor Author

joshka commented Jan 15, 2024

If we wanted all matches to be case insensitive, where could we add a modifier to the regexes? Would a field to handle that be more appropriate? I think that should be the default behavior based on the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants