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

Wrong commit assignment to tags #498

Open
cweber-dbs opened this issue Feb 13, 2024 · 1 comment
Open

Wrong commit assignment to tags #498

cweber-dbs opened this issue Feb 13, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@cweber-dbs
Copy link

cweber-dbs commented Feb 13, 2024

Describe the bug

The assignment of the commits to a tag is based on the creation time of the commits and not based on the topological order of the commits in different branches.

  1. Create a new branch 'feature' from 'main'
  2. Create a commit 'fix: m1' in 'main'
  3. Create a commit 'fix: f1' in 'feature'
  4. Create a commit 'fix: m2' in 'main' and add a tag '1.0.0' to this commit
  5. Create a commit 'fix: f2' in 'feature'
  6. merge 'feature' in main and add a tag '1.1.0' to this merge commit

The created changelog adds commit 'f1' to tag '1.0.0'

Expected behavior

Commits 'fix: m1' and 'fix: m2' should be assigned to Tag '1.0.0.
Commits 'fix: f1' and 'fix: f2' should be assigned to Tag '1.1.0.

Screenshots / Logs
Git Graph of Commits:
image

Created Changelog with wrong assignment:
image

Software information

  • Operating system: macOS 14.3.1
  • Project version: 1.4.0

Additional context

cliff.toml:

# git-cliff ~ 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
"""
# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
{% if version %}\
    {% if previous.version %}\
        ## [{{ version | trim_start_matches(pat="v") }}](${CI_PROJECT_URL}/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 %}\

{% macro commit(commit) -%}
    * {% if commit.scope %}**{{ commit.scope }}:** {% endif %}{% if commit.breaking %}[**breaking**] {% endif %}\
        {{ commit.message | upper_first }} ([{{ commit.id | truncate(length=8, end="") }}](${CI_PROJECT_URL}/-/commit/{{ commit.id }}))\
{% endmacro -%}

{% for group, commits in commits | group_by(attribute="group") %}
    ### {{ group | striptags | trim | upper_first }}
    {% for commit in commits
    | filter(attribute="scope")
    | sort(attribute="scope") %}
        {{ self::commit(commit=commit) }}
    {%- endfor -%}
    {% raw %}\n{% endraw %}\
    {%- for commit in commits %}
        {%- if not commit.scope -%}
            {{ self::commit(commit=commit) }}
        {% endif -%}
    {% endfor -%}
{% endfor %}\n
"""
# template for the changelog footer
footer = """
\n
"""
# remove the leading and trailing whitespace from the templates
trim = true
# postprocessors
postprocessors = []

[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 = []
# regex for parsing and grouping commits
commit_parsers = [
  { message = "^feat", group = "<!-- 0 -->Features" },
  { message = "^fix", group = "<!-- 1 -->Bug Fixes" },
  { message = "^refactor", group = "<!-- 2 -->Refactor" },
  { message = "^perf", group = "<!-- 3 -->Performance" },
  { message = "^revert", group = "<!-- 4 -->Revert" },
]
# protect breaking changes from being skipped due to matching a skipping commit_parser
protect_breaking_commits = true
# filter out the commits that are not matched by commit parsers
filter_commits = true
# regex for matching git tags
tag_pattern = "^v{0,1}[0-9]*\\.[0-9]*\\.[0-9]*.*"
# regex for skipping tags
# skip_tags = "beta|alpha"
# regex for ignoring tags
# ignore_tags = "rc"
# sort the tags topologically
topo_order = false
# sort the commits inside sections by oldest/newest order
sort_commits = "newest"
@cweber-dbs cweber-dbs added the bug Something isn't working label Feb 13, 2024
Copy link

welcome bot commented Feb 13, 2024

Thanks for opening your first issue at git-cliff! Be sure to follow the issue template! ⛰️

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

No branches or pull requests

2 participants