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

not bumped version after squash merge #8

Closed driftertest closed 3 years ago

driftertest commented 3 years ago

Hi, i have another question. I made branch test-111, than i made some commits and run gradlew printVersion + gradle releaseVersion and set tag 0.3.1. Than i merged my branch in dev branch with squash. Now i made test-222 from dev, set 2 commits and when i run gradlew printVersion, it's print me 0.3.1-SNAPSHOT+022.sha.7bab51a. But i expect 0.3.2

10:38:17.974 [DEBUG] [org.eclipse.jgit.internal.storage.file.FileSnapshot] file=/app/.git/config, is unmodified
10:38:17.974 [INFO] [git.semver.plugin.scm.GitProvider] The Git repository is dirty
10:38:17.974 [DEBUG] [git.semver.plugin.scm.GitProvider] added: []
10:38:17.974 [DEBUG] [git.semver.plugin.scm.GitProvider] changed: []
10:38:17.974 [DEBUG] [git.semver.plugin.scm.GitProvider] removed: []
10:38:17.974 [DEBUG] [git.semver.plugin.scm.GitProvider] conflicting: []
10:38:17.975 [DEBUG] [git.semver.plugin.scm.GitProvider] missing: []
10:38:17.975 [DEBUG] [git.semver.plugin.scm.GitProvider] modified: [build.gradle]
10:38:17.976 [DEBUG] [git.semver.plugin.semver.SemVersion] Found version: 0.3.0+sha.de571da in: 'v0.3'
10:38:17.976 [DEBUG] [git.semver.plugin.semver.VersionFinder] Release version found: 0.3.0+sha.de571da
10:38:17.976 [DEBUG] [git.semver.plugin.semver.VersionFinder] Version after commit("Started using Semantic versioning for Gradle"), pre-release(null): 0.3.0+001.sha.3ae727e
..........
10:38:17.977 [DEBUG] [git.semver.plugin.semver.VersionFinder] Version after commit("fix: Update README.md"), pre-release(null): 0.3.0+022.sha.7bab51a
.........
10:38:18.435 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] > Task :printVersion
10:38:18.435 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Task :printVersion' started
10:38:18.435 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter] Putting task artifact state for task ':printVersion' into context took 0.0 secs.
10:38:18.435 [INFO] [org.gradle.internal.execution.steps.ResolveCachingStateStep] Caching disabled for task ':printVersion' because:
  Build cache is disabled
10:38:18.435 [DEBUG] [org.gradle.internal.execution.steps.SkipUpToDateStep] Determining if task ':printVersion' is up-to-date
10:38:18.436 [INFO] [org.gradle.internal.execution.steps.SkipUpToDateStep] Task ':printVersion' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
10:38:18.436 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':printVersion'.
10:38:18.436 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Execute doLast {} action for :printVersion' started
10:38:18.436 [QUIET] [system.out] --------------------
10:38:18.436 [QUIET] [system.out] Version: 0.3.1-SNAPSHOT+022.sha.7bab51a

git tag

[root@3dbb63da6029 app]# git tag -l -n9
v0.3            Merge remote-tracking branch 'origin/dev' into dev
v0.3.1          Release tag set by user

if i set new tag 0.3.2 by 'git tag v0.3.2', i see 0.3.3

root@3dbb63da6029 app]# git tag v0.3.2
[root@3dbb63da6029 app]# git tag
v0.3
v0.3.1
v0.3.2
[root@3dbb63da6029 app]# ./gradlew printVersion

> Configure project :
'lombok.addLombokGeneratedAnnotation = true' is not configured for '/app/src/main/java' of the main source-set

> Task :printVersion
--------------------
Version: 0.3.3-SNAPSHOT+sha.7bab51a

Finished: Tue Aug 10 11:35:52 MSK 2021
jmongard commented 3 years ago

Hi,

When you do squash commit you "loose" every commit from the branch you merged and creates a new commit instead. The plugin will only look at the HEAD commit and any parent commits. There is currently not any option to look at all the tags.

Is the 0.3.2 tag on the branch you squashed from? If it is not on a direct parent commit from HEAD commit it will not be taken into consideration.

I believe there might be other plugins using the tags only approach if that is the desired behaviour.