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

split_commits doesn't work as expected #555

Closed
1 task done
ArtemkaKun opened this issue Mar 14, 2024 · 5 comments · Fixed by #556
Closed
1 task done

split_commits doesn't work as expected #555

ArtemkaKun opened this issue Mar 14, 2024 · 5 comments · Fixed by #556
Assignees
Labels
bug Something isn't working

Comments

@ArtemkaKun
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

When I have a preprocessor, that splits commit messages into 2 commit messages with a new line - none of the commit messages appear in the changelog. When instead of a single \n I put \n\n - only the first commit message appears.

Steps To Reproduce

Config

[changelog]
body = """
{% 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") %}\
    \n
    ## {{ group | upper_first }}\
    {% for group, commits in commits | group_by(attribute="scope") %}\
    	\n
        ### {{ group | upper_first }}\n\
        {% for commit in commits | unique(attribute="message") %}\
            \n- {{ commit.message | split(pat="\n") | first | trim }}\
              {% if commit.github.username %} by @{{ commit.github.username }}{% endif %}\
              {% if commit.github.pr_number %} in #{{ commit.github.pr_number }}{% endif %}\
    	{% endfor %}\
    {% endfor %}\
{% endfor %}\
\n
## First-time contributors 🥳\n\
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}\
    \n- @{{ contributor.username }} made their first contribution in #{{ contributor.pr_number }}\
{% endfor %}\
"""

trim = true

[git]
conventional_commits = true
filter_unconventional = false
split_commits = true

commit_preprocessors = [
    { pattern = '^(fix|feat|setup|doc|refactor|test|optimization)\([A-Za-z0-9_-]+\)(, (fix|feat|setup|doc|refactor|test|optimization)\([A-Za-z0-9_-]+?\))+(:\ .*)', replace = "doc(TEST): test1\ndoc(TEST): test2" },
]

commit_parsers = [
    { message = "^feat", group = "✨ Features" },
    { message = "^fix", group = "🪲 Bug Fixes" },
    { message = "^doc", group = "📚 Documentation" },
    { message = "^optimization", group = "🚀 Performance" },
    { message = "^refactor", group = "🧹 Refactor" },
    { message = "^setup", group = "⚙️ Configuration" },
    { message = "^test", group = "✅ Testing" }, 
]

protect_breaking_commits = false
filter_commits = false
tag_pattern = "v[0-9].*"
skip_tags = ""
ignore_tags = ""
topo_order = false
sort_commits = "oldest"

Expected behavior

Both doc(TEST): test1 and doc(TEST): test2 are visible in the Documentation section in TEST group.

Screenshots / Logs

No response

Software information

Additional context

No response

@ArtemkaKun ArtemkaKun added the bug Something isn't working label Mar 14, 2024
@ArtemkaKun
Copy link
Author

For some reasons, changelog generator can't get a scope of the commits. If I set default_scope manually - now both commits appear in the changelog

@orhun
Copy link
Owner

orhun commented Mar 15, 2024

Hey, #556 should fix this. However, I'm not sure if it is a breaking change. It is quite a bit of an edge case though..

Can you pull the changes from that PR and test it out?

@orhun
Copy link
Owner

orhun commented Mar 15, 2024

Okay something is definitely breaking with that PR, I will take a look

@ArtemkaKun
Copy link
Author

Yes, this is kind of edgecase, because our project uses modified version of conventional commits standard as a compromise between multiple developers.

That's why I want to try to preprocess "not-that-conventional-commit" message to split it on 2 conventional messages and allow changelog generator to handle it without problems.

In my head, the following order should be used:

  1. Preproccesing (both user and own rules)
  2. Filtering conventional/unconventional commits depending on parameters
  3. Generating changelog

However it's probably impossible to satisfy everyone, so in worst case scenario I will make a fork and apply your PR to it, so the tool can be suitable for our needs. So no worries if you can't merge it :)

@orhun
Copy link
Owner

orhun commented Mar 24, 2024

I think I have found a non-breaking way to make it work in #556 - so I will just go ahead with it 🐻

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

Successfully merging a pull request may close this issue.

2 participants