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

Incorrect footers values #130

Closed
rosen-kanev opened this issue Dec 21, 2022 · 3 comments
Closed

Incorrect footers values #130

rosen-kanev opened this issue Dec 21, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@rosen-kanev
Copy link

Describe the bug
It seems that parsing of the footer trailers produces incorrect values with valid git trailers.

To Reproduce
Steps to reproduce the behavior:

  1. Create a commit with the message
fix(example): fix keepachangelog config example

Fixes: #123, #124, #125
  1. Update cliff.toml config with this body to output the footers:
body = """
{% for group, commits in commits | group_by(attribute="group") %}
    ### {{ group | upper_first }}
    {% for commit in commits %}
        - {{ commit.message | upper_first }} ({{ commit.footers | map(attribute="value") | join(sep=", ") }})\
    {% endfor %}
{% endfor %}\n
"""
  1. git-cliff outputs
### Bug Fixes

- Fix keepachangelog config example (, , 125)

Expected behavior

### Bug Fixes

- Fix keepachangelog config example (#123, #124, #125)

Screenshots/Logs
N/A

System (please complete the following information):

  • OS Information: x86_64-apple-darwin (macOS 16.2)
  • Project Version: 0.10.0

Additional context
I'm using git trailers to add the related issues in the commit message. According to its documentation the trailer value may contain whitespace and as a sanity check:

echo "fix(example): fix keepachangelog config example\n\nFixes: #123, #124, #125" | git interpret-trailers --parse # Fixes: #123, #124, #125

When I use git-cliff to generate a changelog the parsing produces unexpected results.

JSON output
[
  {
    "token": "Fixes",
    "separator": ":",
    "value": "",
    "breaking": false
  },
  {
    "token": "#123,",
    "separator": " #",
    "value": "",
    "breaking": false
  },
  {
    "token": "#124,",
    "separator": " #",
    "value": "125",
    "breaking": false
  }
]

Interestingly, using a separate trailer for each related issue like this commit message:

fix(example): fix keepachangelog config example

Fixes: #123
Fixes: #124
Fixes: #125

git-cliff correctly outputs:

### Bug Fixes

- Fix keepachangelog config example (#123, #124, #125)

git log gets too noisy when there are many related issues so I'd rather have them in a comma-separated list.

@rosen-kanev rosen-kanev added the bug Something isn't working label Dec 21, 2022
@orhun
Copy link
Owner

orhun commented Dec 21, 2022

Hi! Thanks for the detailed issue 🐻

Unfortunately this is not possible since such commits are not conventional and cannot be parsed.
Footer object only contains token, separator and value since you normally have <token><separator><value> as your footer. See the specification and footers section in README.md.

using a separate trailer for each related issue

Yes, this is the correct usage of conventional footers.

Feel free to ask in git-conventional to double-check since git-cliff only reflects what it gets from the parser.

@rosen-kanev
Copy link
Author

git-conventional fixed the footer parsing issue crate-ci/git-conventional#34 and it seems like they released a new version with the patch. Any chance that git-cliff cuts a new release as well? Oh btw, congrats on the Dec 25 v1 release 🎉

@orhun
Copy link
Owner

orhun commented Jan 4, 2023

Thank you! I pushed c74fcc2 and it will be available with the next release.

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