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

Enable having a footer like the KeepAChangelog one #95

Closed
MarcoIeni opened this issue Jun 18, 2022 · 4 comments · Fixed by #369
Closed

Enable having a footer like the KeepAChangelog one #95

MarcoIeni opened this issue Jun 18, 2022 · 4 comments · Fixed by #369
Assignees
Labels
feature/request New feature or request

Comments

@MarcoIeni
Copy link
Contributor

Is your feature request related to a problem? Please describe.
In my changelogs, I would like to have a footer like the one of KeepAChangelog:

[Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.3.0...v1.0.0
[0.3.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.2.0...v0.3.0

This enables you to click on the links of each entry of the changelog to see the changes.

I think this isn't possible to achieve at the moment with git-cliff.

Have you ever thought about supporting such a use case?

Describe the solution you'd like

There should be a way for git-cliff to update the footer of the changelog together with the body.

Describe alternatives you've considered
git-cliff could have a new entry in the configuration: version_link, in which the user can specify a template to add after the [<version>]: row.

For example, in the configuration you can have something like:

version_link = """
{% if previous %}\
{% if previous.version %}\
    https://github.com/olivierlacan/keep-a-changelog/compare/{{ previous.version }}...{{ version }}
{% else %}\
    https://github.com/olivierlacan/keep-a-changelog/releases/tag/{{ version }}
{% endif %}\
{% endif %}\
"""

Then, git-cliff takes care of updating the versions at the end of the changelog.

Maybe you could also have a unreleased_link, because the template in this case is different:

unreleased_link = """
    https://github.com/olivierlacan/keep-a-changelog/compare/{{ version }}...HEAD
"""

Additional context
Enabling "templated footers" isn't enough because every time you add a new entry to the changelog, you need to edit the [Unreleased] row with the latest version.

For example, the footer for the 0.3.0 version looks like this:

[Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.3.0...HEAD
[0.3.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.2.0...v0.3.0

Instead the footer of the 1.0.0 version looks like this:

[Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.3.0...v1.0.0
[0.3.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.2.0...v0.3.0

As you can see we have both added the [1.0.0] row, and edited the [Unreleased] one.

@link2xt
Copy link

link2xt commented Nov 17, 2023

I have tried adding this in changelog.body:

{% if version %}\
{% if previous.version %}\
[{{ version | trim_start_matches(pat="v") }}]: https://github.com/deltachat/deltachat-core-rust/compare/{{ previous.version }}..{{ version }}\n
{% endif %}\
{% endif %}

I do not really care about all the links being at the end of file, if they get into the end of section it is fine too.
Then running git cliff -l works as expected.

But unfortunately it does not work when I want to generate a changelog for a version not released yet. If I run git cliff -u -t v1.131.5, I get this:

[1.131.5]: https://github.com/deltachat/deltachat-core-rust/compare/v1.131.5..v1.131.5

I expected previous.version to be set to the latest existing tag.

@orhun
Copy link
Owner

orhun commented Nov 25, 2023

I expected previous.version to be set to the latest existing tag.

Fixed this bug in 6203f77

@link2xt
Copy link

link2xt commented Nov 26, 2023

I expected previous.version to be set to the latest existing tag.

Fixed this bug in 6203f77

Great, thanks!

@orhun
Copy link
Owner

orhun commented Dec 5, 2023

This will be supported when #369 is merged.

@orhun orhun closed this as completed in #369 Dec 5, 2023
orhun added a commit that referenced this issue Dec 5, 2023
* feat(changelog)!: support templating in the footer (#95)

* test(fixture): run test-footer-template fixture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants