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

Allow specifying version and date for unreleased changes #72

Closed
ndarilek opened this issue Mar 23, 2022 · 6 comments
Closed

Allow specifying version and date for unreleased changes #72

ndarilek opened this issue Mar 23, 2022 · 6 comments
Assignees
Labels
feature/request New feature or request

Comments

@ndarilek
Copy link

Is your feature request related to a problem? Please describe.
I want to use git-cliff with cargo-release. Unfortunately there seems to be a bit of a chicken and egg problem in that cargo-release wants to own the tagging process, but git-cliff expects the tag to be added already. So if I want to maintain a project with conventional commits, and generate the changelog as part of the crate, git-cliff generates a changelog as if the newest changes are unreleased, and cargo-release then tags the final release.

Describe the solution you'd like
I'd like to specify versions and an optional date, defaulting to today, for the unreleased section of the changelog. cargo-release exposes these in the environment, so my pre-release hook should be able to generate the changelog and commit the changes as part of its pre-release hook.

Describe alternatives you've considered
I've tried using cargo-release's file processing, but I think this happens before the pre-release hook runs so it wouldn't have access to the new changelog anyway. This may be doable with cargo-release as is, but there's a lot of unclear documentation there, and it just seems easier if I could specify a next tag/date on the command line or in the environment. It might even make sense to adopt cargo-release's conventions as is for these, so running git-cliff directly from a pre-release hook picks up the correct information automatically. The relevant cargo-release environment variable is:

  • NEW_VERSION: The current (bumped) crate version.
    I'm guessing it just defaults the date to today's, which seems sensible for both.

Additional context
Maybe there's a way to do this already, but I haven't found it. Thanks!

@ndarilek ndarilek added the feature/request New feature or request label Mar 23, 2022
@orhun
Copy link
Owner

orhun commented Apr 24, 2022

Hello!

Have you tried git cliff --unreleased --tag <tag> for setting a version (and the current date) for unreleased changes?

@ndarilek
Copy link
Author

I'm using this repository. Note that not all commits are in conventional format since I'm forking a new project and there are things I don't want in the changelog quite yet.

git cliff outputs a full changelog for v0.1.0 and v0.1.1. So far so good.

git cliff --unreleased --tag v0.2.0 is what I assume I'd want to run to cut a new version. That just prints the changelog header and footer. It doesn't print any changelog entries.

git cliff --tag v0.2.0 prints the existing changelog, but doesn't process any new commits.

What I want is something that will cut a release for the untagged v0.2.0, create the changelog with all entries, include unversioned commits as if they're part of this new version, let me commit/tag the release locally, and then CI does the publish. Or maybe some other combination thereof, but right now I can't even generate the next release's changelog.

Thanks.

@alerque
Copy link
Contributor

alerque commented Apr 25, 2022

None of the commits in that repo since v0.1.1 have any conventional-commit log messages. You'll need to setup custom commit message processors to handle your commit message pattern, whatever it is or manually handle the change log for those commits. The reason it generates anything at all for v0.1.0 and v0.1.1 is that there are a handful of conventional-commit compliant messages mixed in there.

@ndarilek
Copy link
Author

OK, got it to work if I a) added a conventional commit message and b) dropped --unreleased. At that point I can specify any arbitrary matching tag not in the repo and have that treated as the newest release, with untagged commits prepended.

I wonder if the --tag option might be changed to clarify that it doesn't need to explicitly specify an existing tag? Maybe add a --current_version/--new_version synonim to make it clearer that you can also specify a version matching the pattern? I've just been assuming that it has to be an existing tag, and that I'd at least get an empty changelog message or something if I'd done it right.

Thanks.

@orhun orhun closed this as completed Apr 28, 2022
@ndarilek
Copy link
Author

ndarilek commented Jun 3, 2022

One more quick question. How do I access the current date in a template? Sometimes the date that I make a release isn't the date that I made the last commit. Still getting the hang of Conventional Commits, but I'm wondering if the current date is exported as a template variable?

Thanks.

@orhun
Copy link
Owner

orhun commented Aug 22, 2022

One more quick question. How do I access the current date in a template? Sometimes the date that I make a release isn't the date that I made the last commit. Still getting the hang of Conventional Commits, but I'm wondering if the current date is exported as a template variable?

You can use now() which is a built-in function.

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

No branches or pull requests

3 participants