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

Problem with version 0.4.2 #12

Closed driftertest closed 2 years ago

driftertest commented 2 years ago

Hi, i'm a little confused, but the plugin stopped working for some reason. The settings did not change, the environment did not change either, since the assembly takes place in a container.

My settings in build.gradle:

semver {
    releaseTagNameFormat = "v%s"
    noDirtyCheck = true
    groupVersionIncrements = true
    noAutoBumb = true
}

The version that is being generated now:

[root@88e629868eb7 app]# ./gradlew printVersion

> Task :printVersion
--------------------
Version: 0.13.24-SNAPSHOT+020.sha.ae5d1cf

If we look at graph of commits, we see that patch version don't bump after "fix" commit. But after version 0.13.23 and 1 "fix" commit we see 0.13.24: Screenshot 2022-04-26 at 16 36 35 2

jmongard commented 2 years ago

Can it be that the plugin find a higher version number in the commit history? If you are using pre-release (e.g. SNAPSHOT) version tags the plugin searches the history until it finds a non pre-release version. e.g. 0.13.24.

You you then try to build upon 0.13.23-SNAPSHOT the plugin is going to find version 0.13.24 that is a later version and return that.

Try running ./gradlew printVersion -d | grep -A1 semver to see what the plugin thinks it find. (The plugin prints version 0.0.0+001 when displaying commits from a branch that has a shared parent from another branch already shown.)

jmongard commented 2 years ago

Also if running from inside github actions make sure you fetch all of the history for the plugin to work with e.g.

    steps:
    - uses: actions/checkout@v2
      with:
          # Disabling shallow clone
          fetch-depth: 0
driftertest commented 1 year ago

Hi, i return to test plugin: config:

semver {
    releaseTagNameFormat = "v%s"
    noDirtyCheck = true
    groupVersionIncrements = false
    noAutoBumb = true
}
  1. I set tag v0.4.0 than created two branches from dev - test1 and test2.
    
    [root@48d71aaecdaf app]# git checkout dev
    Switched to branch 'dev'
    [root@48d71aaecdaf app]# git tag v0.4.0
    [root@48d71aaecdaf app]# ./gradlew printversion

Task :printVersion

Version: 0.4.0+sha.db9d0b8

Finished: Fri Jul 15 10:04:14 MSK 2022 [root@48d71aaecdaf app]# git checkout -b test1 Switched to a new branch 'test1' [root@48d71aaecdaf app]# git checkout dev Switched to branch 'dev' [root@48d71aaecdaf app]# git checkout -b test2 Switched to a new branch 'test2'

2. Set some commits first in branch test1 than test2 and watched to version

[root@48d71aaecdaf app]# git checkout test1 Switched to branch 'test1' [root@48d71aaecdaf app]# git commit --allow-empty -m 'fix: test 11' [test1 062df3f] fix: test 11 [root@48d71aaecdaf app]# ./gradlew printversion

Task :printVersion

Version: 0.4.1-SNAPSHOT+001.sha.062df3f

Finished: Fri Jul 15 10:05:18 MSK 2022

BUILD SUCCESSFUL in 579ms 1 actionable task: 1 executed [root@48d71aaecdaf app]# git commit --allow-empty -m 'fix: test 12' [test1 e9dffd6] fix: test 12 [root@48d71aaecdaf app]# ./gradlew printversion

Task :printVersion

Version: 0.4.2-SNAPSHOT+002.sha.e9dffd6

Finished: Fri Jul 15 10:05:25 MSK 2022

BUILD SUCCESSFUL in 597ms 1 actionable task: 1 executed [root@48d71aaecdaf app]# git commit --allow-empty -m 'fix: test 13' [test1 4f7fd3e] fix: test 13 [root@48d71aaecdaf app]# ./gradlew printversion

Task :printVersion

Merge branch 'test2' into dev Version: 0.4.3-SNAPSHOT+003.sha.4f7fd3e

Finished: Fri Jul 15 10:05:31 MSK 2022

BUILD SUCCESSFUL in 599ms 1 actionable task: 1 executed [root@48d71aaecdaf app]# git checkout test2 Switched to branch 'test2' [root@48d71aaecdaf app]# ./gradlew printversion

Task :printVersion

Version: 0.4.0+sha.db9d0b8

Finished: Fri Jul 15 10:05:38 MSK 2022

BUILD SUCCESSFUL in 587ms 1 actionable task: 1 executed [root@48d71aaecdaf app]# git commit --allow-empty -m 'fix: test 21' [test2 26fc727] fix: test 21 [root@48d71aaecdaf app]# ./gradlew printversion

Task :printVersion

Version: 0.4.1-SNAPSHOT+001.sha.26fc727

Finished: Fri Jul 15 10:05:45 MSK 2022

BUILD SUCCESSFUL in 585ms 1 actionable task: 1 executed [root@48d71aaecdaf app]# git commit --allow-empty -m 'fix: test 22' [test2 824e7b0] fix: test 22 [root@48d71aaecdaf app]# ./gradlew printversion

Task :printVersion

Version: 0.4.2-SNAPSHOT+002.sha.824e7b0

Finished: Fri Jul 15 10:05:53 MSK 2022

BUILD SUCCESSFUL in 568ms 1 actionable task: 1 executed

3. Than i merged test1 to dev and took correct version = 0.4.3-shapshot+003

[root@48d71aaecdaf app]# git branch dev master test1

Task :printVersion

Version: 0.4.3-SNAPSHOT+003.sha.4f7fd3e

Finished: Fri Jul 15 10:07:06 MSK 2022

BUILD SUCCESSFUL in 577ms 1 actionable task: 1 executed

4.Than i merged test2 to dev and took incorrect version 0.4.2-shapshot+007

[root@48d71aaecdaf app]# git merge test2 Already up-to-date! Merge made by the 'recursive' strategy. [root@48d71aaecdaf app]# ./gradlew printversion

Task :printVersion

Version: 0.4.2-SNAPSHOT+007.sha.7420aca

Finished: Fri Jul 15 10:07:29 MSK 2022

BUILD SUCCESSFUL in 550ms 1 actionable task: 1 executed


5. if i will look at 'git log', I'll see all commits

commit 7420aca507ebc8c85259a01adddc8548c215b6d3 Merge: 4f7fd3e 824e7b0 Author: Your Name you@example.com Date: Fri Jul 15 10:07:17 2022 +0300

Merge branch 'test2' into dev

commit 824e7b0e86f62810f8e11dd3654b5aacd4bbaeb8 Author: Your Name you@example.com Date: Fri Jul 15 10:05:49 2022 +0300

fix: test 22

commit 26fc72751be23b3c2247b3dbe526cf97b1a39058 Author: Your Name you@example.com Date: Fri Jul 15 10:05:43 2022 +0300

fix: test 21

commit 4f7fd3e41ebc1fb9e03a3495888aefada601ab15 Author: Your Name you@example.com Date: Fri Jul 15 10:05:28 2022 +0300

fix: test 13

commit e9dffd6bc0c31b5182aa69ec372d63a0bb29e3c1 Author: Your Name you@example.com Date: Fri Jul 15 10:05:22 2022 +0300

fix: test 12

commit 062df3f03c56637a38a35c08af1044f844058163 Author: Your Name you@example.com Date: Fri Jul 15 10:05:11 2022 +0300

fix: test 11

In graph it's lool like this: