gradle-release
gradle-release copied to clipboard
Leading space inserted for title of pre tag commit
Somehow ./gradlew release
inserted a leading space to the commit title for pre tag commit
. This occurred to me with
Gradle 7.5
net.researchgate.release 3.0.0
Kotlin: 1.6.21
Groovy: 3.0.10
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 11.0.14 (Ubuntu 11.0.14+9-Ubuntu-0ubuntu2.20.04)
OS: Linux 5.10.102.1-microsoft-standard-WSL2 amd64
Downgrading the version 3.0.0
to 2.8.1
fixes the issue, i.e., no leading space inserted, see the image below.
I think this must be reproducible if one uses my repo and runs ./gradlew release
, though it is totally unclear to me why this could happen. It seems that GitHub/GitLab interface ignores such leading spaces in commit titles, so one should use git log
to see them.
we also ran into this while we setup workflow rules on skipping commits which started with '[Gradle Release Plugin]'. The pre tag commit slipped through because of the leading space.
Is that extra space from here?: https://github.com/researchgate/gradle-release/blob/af4bf46b51b458ae52ee534ba362632f6f150d57/src/main/groovy/net/researchgate/release/tasks/PreTagCommit.groovy#L26 Our preCommitText is empty, and we get the leading space in the commit message as well.
That seems a logic explanation. Would it make sense to check if preCommitText if empty before prepending it to the message? Maybe the preCommitText should contain [Gradle Release Plugin] and change the other ones like below:
@Input
final Property<String> preCommitText = project.objects.property(String.class).convention('[Gradle Release Plugin] -')
@Input
final Property<String> preTagCommitMessage = project.objects.property(String.class).convention('pre tag commit: ')
@Input
final Property<String> tagCommitMessage = project.objects.property(String.class).convention('creating tag: ')
@Input
final Property<String> newVersionCommitMessage = project.objects.property(String.class).convention('new version commit: ')