jmongard / Git.SemVersioning.Gradle

Gradle plugin for automatically versioning a project using semantic versioning and conventional commits with change log support based on git commit messages.
https://plugins.gradle.org/plugin/com.github.jmongard.git-semver-plugin
Apache License 2.0
38 stars 4 forks source link

"feat:" does not increase MINOR #2

Closed Arc-E-Tect closed 3 years ago

Arc-E-Tect commented 3 years ago

Hi,

First, great plugin. It is serving exactly what I am looking for.

I do have a question though. When I have in my commit comment the text feat: either at the start or anywhere else in the comment, the MINOR is not increased by 1, instead these commits and subsequently pushes only increase the PATCH number.

I have set in my build.gradle file the configuration as follows:

semver {
    defaultPreRelease = "SNAPSHOT"
    releasePattern = "\\Arelease(?:\\(\\w+\\))?:"
    majorPattern = "\\A\\w+(?:\\(\\w+\\))?!:|^BREAKING[ -]CHANGE:"
    minorPattern = "\\Afeat(?:\\(\\w+\\))?:"
    patchPattern = "\\Afix(?:\\(\\w+\\))?:"
    releaseCommitTextFormat = "release: v%s\n\n%s"
    releaseTagNameFormat = "%s"
}

version = semver.version

The README.MD file is not really clear on how the sequence of MINOR and PATCH can be updated or are updated beyond '1'. Could you 'improve' the table (https://github.com/jmongard/Git.SemVersioning.Gradle#example-of-how-version-is-calculated) showing what happens when you do what with increase to for example 0.2.1 and 0.2.2 and 1.0.0?

Thanks again for this great plugin.

jmongard commented 3 years ago

Hi,

Thank you for you interest in the versioning plugin :-)

The default behavior of the plugin is to group version changes together into releases so that a release can have multiple new features without increasing the version more than once until you run gradlew releaseVersion. New commits after this point will again increase the version number once again.

However this grouping behavior might not be desirable so I just added the option groupVersionIncrements that can be set to false and with that every conventional commit message will increase the version number.

By the way you don't have to specify the settings parameters that are not changed from the default value. This would be sufficient to change how the version is calculated:

plugins {
    id "com.github.jmongard.git-semver-plugin" version "0.2.0"
}
semver {
    groupVersionIncrements = false
}

version = semver.version

I hope this is more to your liking.

jmongard commented 3 years ago

With groupVersionIncrements = false git + gradle gives me the following output:

$ gradlew print                                      

> Task :printVersion                                 
--------------------                                 
Version: 10.11.1-SNAPSHOT+057.sha.cea07f9            

BUILD SUCCESSFUL in 2s                               
1 actionable task: 1 executed                        

$ git commit --allow-empty -m "feat: test1"          
[master fbb6e3c1] feat: test1                        

$ gradlew print                                      

> Task :printVersion                                 
--------------------                                 
Version: 10.12.0-SNAPSHOT+058.sha.fbb6e3c            

BUILD SUCCESSFUL in 2s                               
1 actionable task: 1 executed                        

$ git commit --allow-empty -m "feat: test1"          
[master 02a8c2c0] feat: test1                        

$ gradlew print                                      

> Task :printVersion                                 
--------------------                                 
Version: 10.13.0-SNAPSHOT+059.sha.02a8c2c            

BUILD SUCCESSFUL in 2s                               
1 actionable task: 1 executed                        

$ git commit --allow-empty -m "feat: test1"          
[master 9778ff8a] feat: test1                        

$ gradlew print                                      

> Task :printVersion                                 
--------------------                                 
Version: 10.14.0-SNAPSHOT+060.sha.9778ff8            

BUILD SUCCESSFUL in 2s                               
1 actionable task: 1 executed                        

$                                                    
Arc-E-Tect commented 3 years ago

Excellent, this is exactly what I was looking for, Thanks!