qoomon / git-conventional-commits

Git Conventional Commits Util to generate Semantic Version and Markdown Change Log and Validate Commit Messag
https://short.qoo.monster/Conventional-Commits
GNU General Public License v3.0
379 stars 40 forks source link

A reliable way to determine whether a new version should be released #157

Open AlesKrajnik opened 3 months ago

AlesKrajnik commented 3 months ago

Hi,

I am looking for a reliable way how to detect whether a new version should be published based on the commits. E.g. if I only ammend the documentation and then issue npx git-conventional-commits changelog, it produces something like this:

## **0.1.2**&emsp;<sub><sup>2024-07-27 (8695ecb12ef16977c92db2e3090aab77518b5300...eccee0fe03bc3806e978283e9582cb02d55decf8)</sup></sub>

*no relevant changes*
<br>

Similarly, npx git-conventional-commits version will produce a new version number even when there were no relevant changes.

I can of course do something like npx git-conventional-commits changelog | grep "\*no relevant changes\*", but that does not seem to be a sustainable solution.

Would it be possible to have the tool indicate that no new version is needed?

I can think of two different ways:

WDYT?

Thank you!

qoomon commented 3 months ago

Hi, I would go for

adding a flag telling the version command to exit with an error in case there were no relevant changes

qoomon commented 3 months ago

and add same flag for changelog command

qoomon commented 3 months ago

I just came up with another idea.

WDYT?

AlesKrajnik commented 3 months ago

As I see it, it's two questions:

  1. Under what conditions should the version be bumped? Is it the same as "no relevant changes"?
  2. How the tool should behave in case the version should not be bumped?

For the first question, I think it depends on what "no relevant changes" means, or specifically, whether "no relevant" changes" implies the version should not be bumped. If that would be the case, that would mean that if there are no commits with type defined in changelog.commitTypes, then there are "no relevant changes", which in turn means that the version should not be bumped.

The current behaviour is, however, that the version if always bumped, even when the type is not in changelog.commitTypes and also not in convention.commitTypes (https://github.com/qoomon/git-conventional-commits/blob/b39b5a189b8a4252a9a72abcfb85257c5eb7e5fe/lib/gitCommitConvention.js#L51).

So perhaps this should be clarified first - what constitutes no version bump? The official documentation does not really answer that question. It mentions that new version should be bumped for "feat" and "fix" types and all BREAKING CHANGES, however, it does not suggest anything e.g. for docs.

Perhaps we need a new configuration for it? Or can convention.commitTypes be used for it?

For the second question, I would say, it's really a binary question - the version should be either bumped or not. In this case, a simple CLI parameter would IMO do the trick.