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

Add option to refuse to generate a version if the changelog would be empty #43

Open
carlosschults opened this issue Sep 15, 2022 · 1 comment

Comments

@carlosschults
Copy link

I've got a question about one specific behavior of this utility. During my tests, I noticed that whenever I run the command, a new tag is generated and the changelog is updated. This happens even when there are no new commits since the last tag, or when there are commits whose types are different than "feat" or "fix".

My question is: is this the expected behavior, or a bug? In case this is the expected behavior, is it possible to change it via some configuration option? For my use case, I need that nothing happens when there are no additional commits or there are commits marked as "chore", "style", etc.

I tried using the .versionrc file, but the closer I got to what I want is for certain types of commits to not be added to the changelog. However, the changelog entry itself is still created, even if it's empty.

@TimothyJones
Copy link
Member

TimothyJones commented Oct 9, 2022

Apologies for the slow reply.

Yes, this behaviour is expected. When you run the tool, you are asking for a release to be made. If there are no commits that would end up in the changelog, then a release is made incrementing only the patch version.

Personally, this isn't my preferred behaviour - I don't personally want to release if there would be no release notes - because either you missed documenting something in the changelog, or there's nothing that's worth releasing to users.

However, there's currently no option that will allow you to stop a release if there are no changelog changes.

In another project (which used standard-version before it was forked here), I wrote a bit of bash to do a dry run and check the release notes. You can find it here. The relevant part is:

RELEASE_NOTES="$(npx commit-and-tag-version --dry-run | awk 'BEGIN { flag=0 } /^---$/ { if (flag == 0) { flag=1 } else { flag=2 }; next } flag == 1')"
# Don't release if there are no changes
if [ "$(echo "$RELEASE_NOTES" | wc -l)" -eq 1 ] ; then
    error "This release would have no release notes. Does it include changes?"
    echo "   - You must have at least one fix / feat commit to generate release notes"
    echo "*** STOPPING RELEASE PROCESS ***"
    exit 1
fi

It works, but it relies on the log output, which is obviously not ideal.

I think a "don't release if no changelog changes" flag would be a good feature to add.

@TimothyJones TimothyJones changed the title Should a version be generated under these circumstances? Add option to refuse to generate a version if the changelog would be empty Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants