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

Previous not populated when using --latest and skip_tags are set but don't match #44

Closed
iCrawl opened this issue Dec 29, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@iCrawl
Copy link

iCrawl commented Dec 29, 2021

Describe the bug
If skip_tags is defined with a regex that correctly generates the changelog (by skipping the correct/defined ones), there is a regression when setting previous and using --latest which was supposed to be fixed here: #3

But it looks like if you use --latest in combination with skip_tags, even if the pattern should not match the tag at all, it will simply not populate the previous field. This might have been introduced here(?): 7f867ae

If I remove the skip_tags from the config while generating with --latest, previous is populated as expected.

To Reproduce
Steps to reproduce the behavior:

[changelog]
header = """
# Changelog
All notable changes to this project will be documented in this file.\n
"""
body = """
{% if version %}\
    # [{{ version | trim_start_matches(pat="v") }}]\
    {% if previous %}\
        {% if previous.version %}\
            (https://github.com/discordjs/discord.js/compare/{{ previous.version }}...{{ version }})\
        {% else %}
            (https://github.com/discordjs/discord.js/tree/{{ version }}\
        {% endif %}\
    {% endif %} \
    - ({{ 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 %}
        - {% if commit.breaking %}\
            [**breaking**] \
          {% endif %}\
            {% if commit.scope %}\
                **{{commit.scope}}:** \
            {% endif %}\
            {{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}](https://github.com/discordjs/discord.js/commit/{{ commit.id }}))\
    {% endfor %}
{% endfor %}\n
"""
trim = true
footer = ""

[git]
conventional_commits = true
filter_unconventional = true
tag_pattern = "[0-9]*"
skip_tags = "v[0-9]*|11|12"
ignore_tags = ""

All tags on the repo in question:

10.0.0
10.0.1
11.0.0
11.1.0
11.2.0
11.3.0
11.3.1
11.3.2
11.4.0
11.4.1
11.4.2
11.5.0
11.5.1
11.6.0
11.6.1
11.6.2
11.6.3
11.6.4
12.0.0
12.0.1
12.0.2
12.1.0
12.1.1
12.2.0
12.3.0
12.3.1
12.4.0
12.4.1
12.5.0
12.5.1
12.5.2
12.5.3
13.0.0
13.0.1
13.1.0
13.2.0
13.3.0
13.3.1
13.4.0
13.5.0
5.2.0
5.3.2
6.0.0
6.1.0
7.0.0
7.0.1
8.0.0
8.1.0
8.2.0
9.0.2
9.1.0
9.1.1
9.2.0
9.3.0
9.3.1
v5.0.0
v5.0.1
v5.1.0
v5.3.0
v5.3.1

Expected behavior
Expect skip_tags to not drop unrelated tags from the previous field.

System (please complete the following information):

  • OS Information: [Windows 11 Pro / 10.0.22000 Build 22000]
  • Project Version: [0.5.0]
@iCrawl iCrawl added the bug Something isn't working label Dec 29, 2021
@iCrawl iCrawl changed the title Previous not populated when skip_tags are set but don't match Previous not populated when using --latest and skip_tags are set but don't match Dec 29, 2021
@orhun
Copy link
Owner

orhun commented Dec 31, 2021

Hello, good catch!

This should be fixed in 943c23f, can you try it out and let me know if it works as expected?

@iCrawl
Copy link
Author

iCrawl commented Jan 1, 2022

Yes, that did indeed solve it, I do have another question about this, it might be semi-related? Please do tell if you want a separate issue about this but:

Let's presume I want to run something like this:
git cliff --prepend CHANGELOG.md -l which works with the changes/fixes you made now properly and populated previous and everything to correctly give me all the info I need.
But with this approach I need to manually git tag a release, then run the command with the --latest flag to get the diff between the two tags and such the commits.

But ideally, I would want to run something like this:
git cliff --prepend CHANGELOG.md --unreleased --tag 14.0.0

Is this somehow possible or not at all? Since previous does not seem to get populated if I do it this way, without manually creating the tag before.

@orhun
Copy link
Owner

orhun commented Jan 16, 2022

Yes, that did indeed solve it,

Thanks for testing this out!

Please do tell if you want a separate issue about this

Yes, that would be nice 👍🏼

Let's presume I want to run something like this: git cliff --prepend CHANGELOG.md -l which works with the changes/fixes you made now properly and populated previous and everything to correctly give me all the info I need. But with this approach I need to manually git tag a release, then run the command with the --latest flag to get the diff between the two tags and such the commits.

But ideally, I would want to run something like this: git cliff --prepend CHANGELOG.md --unreleased --tag 14.0.0

Is this somehow possible or not at all? Since previous does not seem to get populated if I do it this way, without manually creating the tag before.

This is supposed to be possible. Actually, there is an example command (which is similar to what you gave as an example) in README.md:

# 1- changelog header is removed from CHANGELOG.md
# 2- new entries are prepended to CHANGELOG.md without footer part
git cliff --unreleased --tag 1.0.0 --prepend CHANGELOG.md

So I'm not sure if there is a problem here. Maybe you have a different use-case for --prepend? Feel free to submit another issue about this and I'd be more than happy to work on it 🙂

P.S. Sorry for the late reply.

@orhun orhun closed this as completed Jan 16, 2022
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