From f64596a4e6dce0d83cc4d175b8af882549dbc685 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 29 Aug 2024 22:37:12 +0000 Subject: [PATCH] Update dependency com.javiersc.hubdle to v0.7.8 | datasource | package | from | to | | ---------- | ----------------------------------------------------- | ----- | ----- | | maven | com.javiersc.hubdle:com.javiersc.hubdle.gradle.plugin | 0.7.7 | 0.7.8 | --- CHANGELOG.md | 2 +- .../javiersc/gradle/version/GradleVersion.kt | 59 ++++--- .../gradle/version/GradleVersionTest.kt | 17 +- gradle/libs.versions.toml | 2 +- .../semver/project/gradle/plugin/GitRefs.kt | 5 +- .../project/gradle/plugin/SemverExtension.kt | 10 +- .../project/gradle/plugin/VersionProperty.kt | 4 +- .../gradle/plugin/internal/SemverProperty.kt | 3 +- .../gradle/plugin/internal/git/GitCache.kt | 23 +-- .../internal/git/GitRefGitExtensions.kt | 6 +- .../gradle/plugin/services/GitBuildService.kt | 32 ++-- .../gradle/plugin/tasks/PrintSemverTask.kt | 22 ++- .../gradle/plugin/tasks/WriteSemverTask.kt | 8 +- .../gradle/plugin/CalculatedVersionTest.kt | 23 +-- .../project/gradle/plugin/GitCommitTest.kt | 3 +- .../project/gradle/plugin/GitTagTest.kt | 145 ++++++------------ .../project/gradle/plugin/AssertVersion.kt | 11 +- .../semver/project/gradle/plugin/Sandbox.kt | 35 +++-- .../gradle/plugin/GitHubVariablesTest.kt | 6 +- .../gradle/plugin/GradleFeaturesTest.kt | 4 +- .../gradle/plugin/PushSemverTagTaskTest.kt | 3 +- .../gradle/plugin/VersionBuildDirTest.kt | 3 +- .../examples/MultiProjectExampleTest.kt | 3 +- .../plugin/examples/OneProjectExampleTest.kt | 3 +- 24 files changed, 187 insertions(+), 245 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bdb2d9a..ae26292e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ ### Updated -- `com.javiersc.hubdle:com.javiersc.hubdle.gradle.plugin -> 0.7.7` +- `com.javiersc.hubdle:com.javiersc.hubdle.gradle.plugin -> 0.7.8` ## [0.7.0] - 2024-08-16 diff --git a/gradle-version/main/kotlin/com/javiersc/gradle/version/GradleVersion.kt b/gradle-version/main/kotlin/com/javiersc/gradle/version/GradleVersion.kt index 1b91916a..a113b587 100644 --- a/gradle-version/main/kotlin/com/javiersc/gradle/version/GradleVersion.kt +++ b/gradle-version/main/kotlin/com/javiersc/gradle/version/GradleVersion.kt @@ -10,10 +10,8 @@ import kotlin.contracts.contract import kotlin.text.RegexOption.IGNORE_CASE public class GradleVersion -private constructor( - private val value: String, - checkMode: CheckMode = Insignificant, -) : Comparable { +private constructor(private val value: String, checkMode: CheckMode = Insignificant) : + Comparable { init { if (checkMode == Significant) checkSignificantVersion(value) @@ -91,7 +89,8 @@ private constructor( stageNum = null, commits = commits, hash = hash, - metadata = metadata) + metadata = metadata, + ) } number == null && stageName.isBlank() -> { invoke( @@ -102,7 +101,8 @@ private constructor( stageNum = null, commits = commits, hash = hash, - metadata = metadata) + metadata = metadata, + ) } number == null && stageName.isNotBlank() && stage?.name.isNullOrBlank() -> { invoke( @@ -113,7 +113,8 @@ private constructor( stageNum = incNum, commits = commits, hash = hash, - metadata = metadata) + metadata = metadata, + ) } number == null && stageName.isNotBlank() && stageName == stage?.name -> { invoke( @@ -124,7 +125,8 @@ private constructor( stageNum = stage.num?.inc(), commits = commits, hash = hash, - metadata = metadata) + metadata = metadata, + ) } number == null && stageName.isNotBlank() && stageName != stage?.name -> { invoke( @@ -135,7 +137,8 @@ private constructor( stageNum = incNum, commits = commits, hash = hash, - metadata = metadata) + metadata = metadata, + ) } number is Increase.Major && stageName.isBlank() -> { invoke( @@ -146,7 +149,8 @@ private constructor( stageNum = null, commits = commits, hash = hash, - metadata = metadata) + metadata = metadata, + ) } number is Increase.Minor && stageName.isBlank() -> { invoke( @@ -157,7 +161,8 @@ private constructor( stageNum = null, commits = commits, hash = hash, - metadata = metadata) + metadata = metadata, + ) } number is Increase.Patch && stageName.isBlank() -> { invoke( @@ -168,7 +173,8 @@ private constructor( stageNum = null, commits = commits, hash = hash, - metadata = metadata) + metadata = metadata, + ) } number is Increase.Major && stageName.isNotBlank() -> { invoke( @@ -179,7 +185,8 @@ private constructor( stageNum = incNum, commits = commits, hash = hash, - metadata = metadata) + metadata = metadata, + ) } number is Increase.Minor && stageName.isNotBlank() -> { invoke( @@ -190,7 +197,8 @@ private constructor( stageNum = incNum, commits = commits, hash = hash, - metadata = metadata) + metadata = metadata, + ) } number is Increase.Patch && stageName.isNotBlank() -> { invoke( @@ -201,14 +209,16 @@ private constructor( stageNum = incNum, commits = commits, hash = hash, - metadata = metadata) + metadata = metadata, + ) } else -> null } ?: gradleVersionError("There were an error configuring the version") if (nextVersion < this) { gradleVersionError( - "Next version ($nextVersion) should be higher than the current one ($this)") + "Next version ($nextVersion) should be higher than the current one ($this)" + ) } return nextVersion } @@ -366,7 +376,16 @@ private constructor( checkMode: CheckMode = Insignificant, ): Result = runCatching { GradleVersion( - major, minor, patch, stageName, stageNum, commits, hash, metadata, checkMode) + major, + minor, + patch, + stageName, + stageNum, + commits, + hash, + metadata, + checkMode, + ) } public fun getOrNull( @@ -459,10 +478,8 @@ private constructor( } } - internal class SpecialStage - private constructor( - private val stage: Stage, - ) : Comparable { + internal class SpecialStage private constructor(private val stage: Stage) : + Comparable { override fun compareTo(other: SpecialStage): Int { val name = stage.name.lowercase() diff --git a/gradle-version/test/kotlin/com/javiersc/gradle/version/GradleVersionTest.kt b/gradle-version/test/kotlin/com/javiersc/gradle/version/GradleVersionTest.kt index d5521c98..4ddce0b4 100644 --- a/gradle-version/test/kotlin/com/javiersc/gradle/version/GradleVersionTest.kt +++ b/gradle-version/test/kotlin/com/javiersc/gradle/version/GradleVersionTest.kt @@ -40,18 +40,11 @@ internal class GradleVersionTest { Arb.constant("rc"), Arb.constant("SNAPSHOT"), Arb.constant("zasca"), - Arb.constant(null)) - private val num = - Arb.choice( - Arb.positiveInt(11), Arb.constant(null), ) + private val num = Arb.choice(Arb.positiveInt(11), Arb.constant(null)) - private val commits = - Arb.choice( - Arb.positiveInt(11), - Arb.constant(null), - ) + private val commits = Arb.choice(Arb.positiveInt(11), Arb.constant(null)) private val hash = Arb.choice( @@ -61,7 +54,8 @@ internal class GradleVersionTest { Arb.constant("4Hash3h"), Arb.constant("0h2az2U"), Arb.constant("102aY20"), - Arb.constant(null)) + Arb.constant(null), + ) private val metadata = Arb.choice( @@ -75,7 +69,8 @@ internal class GradleVersionTest { Arb.constant("777777777"), Arb.constant("AAAA"), Arb.constant("BBBBBBBBB"), - Arb.constant(null)) + Arb.constant(null), + ) private val versionArbitrary: Arb = arbitrary { val major: Int = major.bind() diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6631105b..db1218b1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -hubdle = "0.7.7" +hubdle = "0.7.8" [plugins] javiersc-hubdle = { id = "com.javiersc.hubdle", version.ref = "hubdle" } diff --git a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/GitRefs.kt b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/GitRefs.kt index 8bbf7f5b..410cfcf4 100644 --- a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/GitRefs.kt +++ b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/GitRefs.kt @@ -27,9 +27,6 @@ public data class Commit( * @param name The name of the tag, example: `v1.0.0` * @param refName The name of the ref, example: `refs/tags/v1.0.0` */ -public data class Tag( - val name: String, - val refName: String, -) { +public data class Tag(val name: String, val refName: String) { override fun toString(): String = name } diff --git a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/SemverExtension.kt b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/SemverExtension.kt index e90f34d2..8d52db65 100644 --- a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/SemverExtension.kt +++ b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/SemverExtension.kt @@ -18,10 +18,7 @@ import org.gradle.kotlin.dsl.property public abstract class SemverExtension @Inject -constructor( - objects: ObjectFactory, - providers: ProviderFactory, -) { +constructor(objects: ObjectFactory, providers: ProviderFactory) { public val isEnabled: Property = objects.property().convention(true) @@ -29,10 +26,7 @@ constructor( public val commits: Provider> = providers.provider { - GitCache( - gitDir = gitDir.get().asFile, - maxCount = commitsMaxCount, - ) + GitCache(gitDir = gitDir.get().asFile, maxCount = commitsMaxCount) .commitsInTheCurrentBranchPublicApi } diff --git a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/VersionProperty.kt b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/VersionProperty.kt index f1960795..60fa317e 100644 --- a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/VersionProperty.kt +++ b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/VersionProperty.kt @@ -2,9 +2,7 @@ package com.javiersc.semver.project.gradle.plugin import org.gradle.api.provider.Provider -public class VersionProperty( - private val version: Provider, -) : Provider by version { +public class VersionProperty(private val version: Provider) : Provider by version { override fun toString(): String = "${version.orNull}" } diff --git a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/internal/SemverProperty.kt b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/internal/SemverProperty.kt index 71fa7acf..a985d829 100644 --- a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/internal/SemverProperty.kt +++ b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/internal/SemverProperty.kt @@ -52,8 +52,7 @@ internal enum class SemverProperty(val key: String) { internal enum class Stage(private val value: String) { Auto("auto"), - Final("final"), - ; + Final("final"); operator fun invoke(): String = value } diff --git a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/internal/git/GitCache.kt b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/internal/git/GitCache.kt index 8a5ee344..11f4db55 100644 --- a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/internal/git/GitCache.kt +++ b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/internal/git/GitCache.kt @@ -26,10 +26,7 @@ private val checkedNotNullCache: GitCache private var gitCache: GitCache? = null internal class GitCache -private constructor( - private val gitDir: File, - maxCount: Provider? = null, -) { +private constructor(private val gitDir: File, maxCount: Provider? = null) { internal val git: Git by lazy { Git(FileRepositoryBuilder().setGitDir(gitDir).readEnvironment().findGitDir().build()).also { @@ -54,7 +51,7 @@ private constructor( message = headRevCommit.shortMessage, fullMessage = headRevCommit.fullMessage, hash = headRevCommit.toObjectId().name, - ), + ) ) } @@ -73,12 +70,7 @@ private constructor( val tags: List = tagsInCurrentBranchRef .filter { ref -> commitHash(ref) == hash } - .map { ref -> - Tag( - name = ref.tagName, - refName = ref.name, - ) - } + .map { ref -> Tag(name = ref.tagName, refName = ref.name) } Commit( message = revCommit.shortMessage, fullMessage = revCommit.fullMessage, @@ -131,7 +123,8 @@ private constructor( message = commit.shortMessage, fullMessage = commit.fullMessage, hash = commit.toObjectId().name, - )) + ), + ) } internal fun tagsInCurrentCommit(hash: String): List = @@ -185,9 +178,9 @@ private constructor( val higherVersion: GradleVersion? = versionsInCurrentBranch(tagPrefix).firstOrNull() - if (lastVersion != null && - higherVersion != null && - higherVersion > lastVersion) { + if ( + lastVersion != null && higherVersion != null && higherVersion > lastVersion + ) { isWarningLastVersionIsNotHigherVersion(true) warningLastVersionIsNotHigherVersion(lastVersion, higherVersion) } diff --git a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/internal/git/GitRefGitExtensions.kt b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/internal/git/GitRefGitExtensions.kt index b5837b48..72baede7 100644 --- a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/internal/git/GitRefGitExtensions.kt +++ b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/internal/git/GitRefGitExtensions.kt @@ -26,7 +26,8 @@ internal val Git.headCommit: GitRef.Head message = headRevCommit.shortMessage, fullMessage = headRevCommit.fullMessage, hash = headRevCommit.toObjectId().name, - )) + ) + ) internal val Git.headRevCommit: RevCommit get() = RevWalk(repository).parseCommit(repository.resolve(Constants.HEAD)) @@ -97,7 +98,8 @@ internal val Git.tagsInRepo: List message = commit.shortMessage, fullMessage = commit.fullMessage, hash = commit.toObjectId().name, - )) + ), + ) } internal val Git.tagsInRepoRef: List diff --git a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/services/GitBuildService.kt b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/services/GitBuildService.kt index 93f2abbd..8ff646b6 100644 --- a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/services/GitBuildService.kt +++ b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/services/GitBuildService.kt @@ -21,20 +21,15 @@ import org.gradle.process.ExecOperations public abstract class GitBuildService @Inject -constructor( - private val execOperations: ExecOperations, -) : BuildService, AutoCloseable { +constructor(private val execOperations: ExecOperations) : + BuildService, AutoCloseable { private val createdTagPrefixes: MutableSet = mutableSetOf() private val git: Git get() = parameters.run { - GitCache( - gitDir = gitDir.get().asFile, - maxCount = commitsMaxCount, - ) - .git + GitCache(gitDir = gitDir.get().asFile, maxCount = commitsMaxCount).git } internal fun createTag(tagPrefixProperty: String, projectTagPrefix: String, version: String) { @@ -91,16 +86,17 @@ constructor( internal fun register(project: Project): Provider = project.gradle.sharedServices.registerIfAbsent( - "gitTagBuildService", GitBuildService::class) { buildService -> - val commitsMaxCount: Int = - project.commitsMaxCount.orNull - ?: project.semverExtension.commitsMaxCount.get() - buildService.parameters.gitDir.set(project.semverExtension.gitDir) - buildService.parameters.commitsMaxCount.set(commitsMaxCount) - buildService.parameters.remoteProperty.set(project.remoteProperty) - - buildService.maxParallelUsages.set(1) - } + "gitTagBuildService", + GitBuildService::class, + ) { buildService -> + val commitsMaxCount: Int = + project.commitsMaxCount.orNull ?: project.semverExtension.commitsMaxCount.get() + buildService.parameters.gitDir.set(project.semverExtension.gitDir) + buildService.parameters.commitsMaxCount.set(commitsMaxCount) + buildService.parameters.remoteProperty.set(project.remoteProperty) + + buildService.maxParallelUsages.set(1) + } } } diff --git a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/tasks/PrintSemverTask.kt b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/tasks/PrintSemverTask.kt index b09f7a34..5e7e75f1 100644 --- a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/tasks/PrintSemverTask.kt +++ b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/tasks/PrintSemverTask.kt @@ -42,42 +42,47 @@ constructor( @Input @Option( option = "githubOnlyRoot", - description = "Set any GitHub option to work only on the root project `printSemver` task") + description = "Set any GitHub option to work only on the root project `printSemver` task", + ) public val githubOnlyRoot: Property = objects.property().convention(false) @Input @Option( option = "githubEnvTag", description = - "Set the version as `semver-tag-subproject-name` environment variable of the GitHub Actions") + "Set the version as `semver-tag-subproject-name` environment variable of the GitHub Actions", + ) public val githubEnvTag: Property = objects.property().convention(false) @Input @Option( option = "githubEnvVersion", description = - "Set the version as `semver-version-subproject-name` environment variable of the GitHub Actions") + "Set the version as `semver-version-subproject-name` environment variable of the GitHub Actions", + ) public val githubEnvVersion: Property = objects.property().convention(false) @Input @Option( option = "githubEnv", description = - "Set the version as `semver-subproject-name` environment variable of the GitHub Actions") + "Set the version as `semver-subproject-name` environment variable of the GitHub Actions", + ) public val githubEnv: Property = objects.property().convention(false) @Input @Option( option = "githubOutputTag", - description = - "Set the version as `semver-tag-subproject-name` output of the GitHub Actions") + description = "Set the version as `semver-tag-subproject-name` output of the GitHub Actions", + ) public val githubOutputTag: Property = objects.property().convention(false) @Input @Option( option = "githubOutputVersion", description = - "Set the version as `semver-version-subproject-name` output of the GitHub Actions") + "Set the version as `semver-version-subproject-name` output of the GitHub Actions", + ) public val githubOutputVersion: Property = objects.property().convention(false) @@ -85,7 +90,8 @@ constructor( @Option( option = "githubOutput", description = - "Set the version as `semver-subproject-name` output of the GitHub Actions `semver` step ID") + "Set the version as `semver-subproject-name` output of the GitHub Actions `semver` step ID", + ) public val githubOutput: Property = objects.property().convention(false) @get:Input public abstract val shouldLogMessage: Property diff --git a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/tasks/WriteSemverTask.kt b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/tasks/WriteSemverTask.kt index 7cd5ae1b..f34f54fe 100644 --- a/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/tasks/WriteSemverTask.kt +++ b/semver-project-gradle-plugin/main/kotlin/com/javiersc/semver/project/gradle/plugin/tasks/WriteSemverTask.kt @@ -24,10 +24,7 @@ import org.gradle.language.base.plugins.LifecycleBasePlugin.CHECK_TASK_NAME @CacheableTask public abstract class WriteSemverTask @Inject -constructor( - objects: ObjectFactory, - layout: ProjectLayout, -) : DefaultTask() { +constructor(objects: ObjectFactory, layout: ProjectLayout) : DefaultTask() { init { group = "semver" @@ -56,7 +53,8 @@ constructor( |$semverWithPrefix | """ - .trimMargin()) + .trimMargin() + ) } } diff --git a/semver-project-gradle-plugin/test/kotlin/com/javiersc/semver/project/gradle/plugin/CalculatedVersionTest.kt b/semver-project-gradle-plugin/test/kotlin/com/javiersc/semver/project/gradle/plugin/CalculatedVersionTest.kt index a2d90eb8..f0fb49a6 100644 --- a/semver-project-gradle-plugin/test/kotlin/com/javiersc/semver/project/gradle/plugin/CalculatedVersionTest.kt +++ b/semver-project-gradle-plugin/test/kotlin/com/javiersc/semver/project/gradle/plugin/CalculatedVersionTest.kt @@ -22,7 +22,8 @@ internal class CalculatedVersionTest { commits = 0, hash = git.lastCommitInCurrentBranch!!.hash.take(7), metadata = null, - )) + ) + ) resolve("2 commit.txt").createNewFile() @@ -32,7 +33,8 @@ internal class CalculatedVersionTest { commits = 0, hash = git.lastCommitInCurrentBranch!!.hash.take(7), metadata = "DIRTY", - )) + ) + ) git.add().addFilepattern(".").call() git.commit().setMessage("2 commit").call() @@ -43,22 +45,12 @@ internal class CalculatedVersionTest { resolve("3 commit.txt").createNewFile() git.calculateAdditionalVersionData(tagPrefix = "v") - .shouldBe( - AdditionalVersionData( - commits = 0, - hash = null, - metadata = "DIRTY", - )) + .shouldBe(AdditionalVersionData(commits = 0, hash = null, metadata = "DIRTY")) git.add().addFilepattern(".").call() git.calculateAdditionalVersionData(tagPrefix = "v") - .shouldBe( - AdditionalVersionData( - commits = 0, - hash = null, - metadata = "DIRTY", - )) + .shouldBe(AdditionalVersionData(commits = 0, hash = null, metadata = "DIRTY")) git.commit().setMessage("3 commit").call() @@ -68,7 +60,8 @@ internal class CalculatedVersionTest { commits = 1, hash = git.lastCommitInCurrentBranch!!.hash.take(7), metadata = null, - )) + ) + ) } } diff --git a/semver-project-gradle-plugin/test/kotlin/com/javiersc/semver/project/gradle/plugin/GitCommitTest.kt b/semver-project-gradle-plugin/test/kotlin/com/javiersc/semver/project/gradle/plugin/GitCommitTest.kt index a4dad382..9f1ed98a 100644 --- a/semver-project-gradle-plugin/test/kotlin/com/javiersc/semver/project/gradle/plugin/GitCommitTest.kt +++ b/semver-project-gradle-plugin/test/kotlin/com/javiersc/semver/project/gradle/plugin/GitCommitTest.kt @@ -56,7 +56,8 @@ internal class GitCommitTest { git.commitsInCurrentBranchRevCommit.map(RevCommit::getShortMessage).shouldBe(messages) git.commitsInCurrentBranch.map(GitRef.Commit::message).shouldBe(messages) git.commitsInCurrentBranchHash.shouldBe( - git.commitsInCurrentBranch.map(GitRef.Commit::hash)) + git.commitsInCurrentBranch.map(GitRef.Commit::hash) + ) } } diff --git a/semver-project-gradle-plugin/test/kotlin/com/javiersc/semver/project/gradle/plugin/GitTagTest.kt b/semver-project-gradle-plugin/test/kotlin/com/javiersc/semver/project/gradle/plugin/GitTagTest.kt index bdb15a5e..e2d5f626 100644 --- a/semver-project-gradle-plugin/test/kotlin/com/javiersc/semver/project/gradle/plugin/GitTagTest.kt +++ b/semver-project-gradle-plugin/test/kotlin/com/javiersc/semver/project/gradle/plugin/GitTagTest.kt @@ -117,11 +117,8 @@ internal class GitTagTest { git.tag().setName("vhello").call() git.tag().setName("v100").call() git.tagsInRepoName.shouldBe( - listOf( - "refs/tags/hello", - "refs/tags/v100", - "refs/tags/vhello", - )) + listOf("refs/tags/hello", "refs/tags/v100", "refs/tags/vhello") + ) resolve("Second commit.txt").createNewFile() git.add().addFilepattern(".").call() @@ -129,12 +126,8 @@ internal class GitTagTest { git.tag().setName("v3.0.0").call() git.tagsInRepoName.shouldBe( - listOf( - "refs/tags/hello", - "refs/tags/v100", - "refs/tags/v3.0.0", - "refs/tags/vhello", - )) + listOf("refs/tags/hello", "refs/tags/v100", "refs/tags/v3.0.0", "refs/tags/vhello") + ) git.tag().setName("v1.0.0").call() git.tagsInRepoName.shouldBe( @@ -144,7 +137,8 @@ internal class GitTagTest { "refs/tags/v100", "refs/tags/v3.0.0", "refs/tags/vhello", - )) + ) + ) git.tag().setName("v2.0.0").call() git.tag().setName("v200").call() @@ -159,7 +153,8 @@ internal class GitTagTest { "refs/tags/v200", "refs/tags/v3.0.0", "refs/tags/vhello", - )) + ) + ) } } @@ -171,12 +166,7 @@ internal class GitTagTest { git.tag().setName("v100").call() git.tagsInCurrentBranch .map(GitRef.Tag::name) - .shouldBe( - listOf( - "hello", - "v100", - "vhello", - )) + .shouldBe(listOf("hello", "v100", "vhello")) resolve("Second commit.txt").createNewFile() git.add().addFilepattern(".").call() @@ -185,25 +175,12 @@ internal class GitTagTest { git.tag().setName("v3.0.0").call() git.tagsInCurrentBranch .map(GitRef.Tag::name) - .shouldBe( - listOf( - "hello", - "v100", - "v3.0.0", - "vhello", - )) + .shouldBe(listOf("hello", "v100", "v3.0.0", "vhello")) git.tag().setName("v1.0.0").call() git.tagsInCurrentBranch .map(GitRef.Tag::name) - .shouldBe( - listOf( - "hello", - "v1.0.0", - "v100", - "v3.0.0", - "vhello", - )) + .shouldBe(listOf("hello", "v1.0.0", "v100", "v3.0.0", "vhello")) git.tag().setName("v2.0.0").call() git.tag().setName("v200").call() @@ -220,7 +197,8 @@ internal class GitTagTest { "v200", "v3.0.0", "vhello", - )) + ) + ) } } @@ -230,14 +208,7 @@ internal class GitTagTest { git.tag().setName("hello").call() git.tag().setName("vhello").call() git.tag().setName("v100").call() - git.tagsInCurrentBranchRef - .map(Ref::tagName) - .shouldBe( - listOf( - "hello", - "v100", - "vhello", - )) + git.tagsInCurrentBranchRef.map(Ref::tagName).shouldBe(listOf("hello", "v100", "vhello")) resolve("Second commit.txt").createNewFile() git.add().addFilepattern(".").call() @@ -246,25 +217,12 @@ internal class GitTagTest { git.tag().setName("v3.0.0").call() git.tagsInCurrentBranchRef .map(Ref::tagName) - .shouldBe( - listOf( - "hello", - "v100", - "v3.0.0", - "vhello", - )) + .shouldBe(listOf("hello", "v100", "v3.0.0", "vhello")) git.tag().setName("v1.0.0").call() git.tagsInCurrentBranchRef .map(Ref::tagName) - .shouldBe( - listOf( - "hello", - "v1.0.0", - "v100", - "v3.0.0", - "vhello", - )) + .shouldBe(listOf("hello", "v1.0.0", "v100", "v3.0.0", "vhello")) git.tag().setName("v2.0.0").call() git.tag().setName("v200").call() @@ -281,7 +239,8 @@ internal class GitTagTest { "v200", "v3.0.0", "vhello", - )) + ) + ) } } @@ -322,11 +281,8 @@ internal class GitTagTest { git.tag().setName("vhello").call() git.tag().setName("v100").call() git.tagsInCurrentBranchName.shouldBe( - listOf( - "refs/tags/hello", - "refs/tags/v100", - "refs/tags/vhello", - )) + listOf("refs/tags/hello", "refs/tags/v100", "refs/tags/vhello") + ) resolve("Second commit.txt").createNewFile() git.add().addFilepattern(".").call() @@ -334,12 +290,8 @@ internal class GitTagTest { git.tag().setName("v3.0.0").call() git.tagsInCurrentBranchName.shouldBe( - listOf( - "refs/tags/hello", - "refs/tags/v100", - "refs/tags/v3.0.0", - "refs/tags/vhello", - )) + listOf("refs/tags/hello", "refs/tags/v100", "refs/tags/v3.0.0", "refs/tags/vhello") + ) git.tag().setName("v1.0.0").call() git.tagsInCurrentBranchName.shouldBe( @@ -349,7 +301,8 @@ internal class GitTagTest { "refs/tags/v100", "refs/tags/v3.0.0", "refs/tags/vhello", - )) + ) + ) git.tag().setName("v2.0.0").call() git.tag().setName("v200").call() @@ -364,7 +317,8 @@ internal class GitTagTest { "refs/tags/v200", "refs/tags/v3.0.0", "refs/tags/vhello", - )) + ) + ) } } @@ -376,12 +330,7 @@ internal class GitTagTest { git.tag().setName("v100").call() git.tagsInCurrentCommit(git.headCommit.commit.hash) .map(GitRef.Tag::name) - .shouldBe( - listOf( - "hello", - "v100", - "vhello", - )) + .shouldBe(listOf("hello", "v100", "vhello")) resolve("Second commit.txt").createNewFile() git.add().addFilepattern(".").call() @@ -390,23 +339,14 @@ internal class GitTagTest { git.tag().setName("v1.0.0").call() git.tagsInCurrentCommit(git.headCommit.commit.hash) .map(GitRef.Tag::name) - .shouldBe( - listOf( - "v1.0.0", - )) + .shouldBe(listOf("v1.0.0")) git.tag().setName("v2.0.0").call() git.tag().setName("v200").call() git.tag().setName("v20.20").call() git.tagsInCurrentCommit(git.headCommit.commit.hash) .map(GitRef.Tag::name) - .shouldBe( - listOf( - "v1.0.0", - "v2.0.0", - "v20.20", - "v200", - )) + .shouldBe(listOf("v1.0.0", "v2.0.0", "v20.20", "v200")) } } @@ -512,7 +452,8 @@ internal class GitTagTest { "v1.0.0-alpha.22", "v2.0.0", "v3.0.0", - )) + ) + ) git.tag().setName("v1.0.0-rc.22").call() git.tag().setName("v1.0.0-rc.11").call() @@ -536,7 +477,8 @@ internal class GitTagTest { "v1.0.0-rc.22", "v2.0.0", "v3.0.0", - )) + ) + ) git.tag().setName("v200").call() git.tag().setName("v20.20").call() @@ -557,7 +499,8 @@ internal class GitTagTest { "v1.0.0-rc.22", "v2.0.0", "v3.0.0", - )) + ) + ) } } @@ -605,7 +548,8 @@ internal class GitTagTest { "v1.0.0", "v2.0.0", "v3.0.0", - )) + ) + ) git.tag().setName("v1.0.0-rc.22").call() git.tag().setName("v1.0.0-rc.11").call() @@ -630,7 +574,8 @@ internal class GitTagTest { "v1.0.0", "v2.0.0", "v3.0.0", - )) + ) + ) git.tag().setName("v200").call() git.tag().setName("v20.20").call() @@ -652,7 +597,8 @@ internal class GitTagTest { "v1.0.0", "v2.0.0", "v3.0.0", - )) + ) + ) } } @@ -704,7 +650,8 @@ internal class GitTagTest { "v1.0.0", "v2.0.0", "v3.0.0", - )) + ) + ) git.tag().setName("v1.0.0-rc.22").call() git.tag().setName("v1.0.0-rc.11").call() @@ -729,7 +676,8 @@ internal class GitTagTest { "v1.0.0", "v2.0.0", "v3.0.0", - )) + ) + ) git.tag().setName("v200").call() git.tag().setName("v20.20").call() @@ -751,7 +699,8 @@ internal class GitTagTest { "v1.0.0", "v2.0.0", "v3.0.0", - )) + ) + ) } } diff --git a/semver-project-gradle-plugin/testFixtures/kotlin/com/javiersc/semver/project/gradle/plugin/AssertVersion.kt b/semver-project-gradle-plugin/testFixtures/kotlin/com/javiersc/semver/project/gradle/plugin/AssertVersion.kt index 697ef7f6..cccba733 100644 --- a/semver-project-gradle-plugin/testFixtures/kotlin/com/javiersc/semver/project/gradle/plugin/AssertVersion.kt +++ b/semver-project-gradle-plugin/testFixtures/kotlin/com/javiersc/semver/project/gradle/plugin/AssertVersion.kt @@ -45,11 +45,7 @@ fun assertVersionFromExpectVersionFile(file: File) { file.assertVersion(tagPrefix, sanitizeVersion, insignificant) } -fun File.assertVersion( - prefix: String, - version: String, - insignificant: Insignificant? = null, -) { +fun File.assertVersion(prefix: String, version: String, insignificant: Insignificant? = null) { val buildVersionFile = resolve("build/semver/version.txt") val buildVersion = buildVersionFile.readLines().first() val buildTagVersion = buildVersionFile.readLines()[1] @@ -76,7 +72,8 @@ fun File.assertVersion( |$prefix$version | """ - .trimMargin()) + .trimMargin() + ) } } } @@ -86,7 +83,7 @@ private fun printExpectedAndActualVersions( version: String, insignificant: Insignificant?, buildTagVersion: String, - prefix: String + prefix: String, ) { val insignificantText = if (insignificant != null) "+$insignificant" else "" val actualVersion = "ACTUAL: $buildVersion".ansiColor(Yellow) diff --git a/semver-project-gradle-plugin/testFixtures/kotlin/com/javiersc/semver/project/gradle/plugin/Sandbox.kt b/semver-project-gradle-plugin/testFixtures/kotlin/com/javiersc/semver/project/gradle/plugin/Sandbox.kt index ee68f043..09c62d59 100644 --- a/semver-project-gradle-plugin/testFixtures/kotlin/com/javiersc/semver/project/gradle/plugin/Sandbox.kt +++ b/semver-project-gradle-plugin/testFixtures/kotlin/com/javiersc/semver/project/gradle/plugin/Sandbox.kt @@ -18,7 +18,8 @@ val GradleRunner.git: Git .setGitDir(File("$projectDir/.git")) .readEnvironment() .findGitDir() - .build()) + .build() + ) val File.git: Git get() = @@ -27,7 +28,8 @@ val File.git: Git .setGitDir(resolve(".git")) .readEnvironment() .findGitDir() - .build()) + .build() + ) fun getResource(resource: String): File = File(Thread.currentThread().contextClassLoader?.getResource(resource)?.toURI()!!) @@ -63,22 +65,23 @@ fun File.generateInitialCommitAddVersionTagAndAddNewCommit( fullMessage = "Add new2", hash = "f099fed42808c387d38f8e34934d4ef2d6f3c2c5", timestampEpochSecond = Instant.now().epochSecond, - tags = emptyList()), + tags = emptyList(), + ), Commit( message = "Add new", fullMessage = "Add new", hash = "0d9be4d12a836435c91fc38e0d64bcd3c14c89c8", timestampEpochSecond = Instant.now().epochSecond, - tags = emptyList()), + tags = emptyList(), + ), Commit( message = "Initial commit", fullMessage = "Initial commit", hash = "e2592aafc259bd797e32f1ea4fe60cc7c0698f70", timestampEpochSecond = Instant.now().epochSecond, - tags = - listOf( - Tag(name = "1.0.0", refName = "refs/tags/1.0.0"), - ))) + tags = listOf(Tag(name = "1.0.0", refName = "refs/tags/1.0.0")), + ), + ) } // `this` is `projectDir` @@ -104,22 +107,23 @@ fun File.generateInitialCommitAddVersionTag( fullMessage = "Add new2", hash = "f099fed42808c387d38f8e34934d4ef2d6f3c2c5", timestampEpochSecond = Instant.now().epochSecond, - tags = emptyList()), + tags = emptyList(), + ), Commit( message = "Add new", fullMessage = "Add new", hash = "0d9be4d12a836435c91fc38e0d64bcd3c14c89c8", timestampEpochSecond = Instant.now().epochSecond, - tags = emptyList()), + tags = emptyList(), + ), Commit( message = "Initial commit", fullMessage = "Initial commit", hash = "e2592aafc259bd797e32f1ea4fe60cc7c0698f70", timestampEpochSecond = Instant.now().epochSecond, - tags = - listOf( - Tag(name = "1.0.0", refName = "refs/tags/1.0.0"), - ))) + tags = listOf(Tag(name = "1.0.0", refName = "refs/tags/1.0.0")), + ), + ) } fun File.createGitIgnore() { @@ -135,7 +139,8 @@ fun File.createGitIgnore() { |environment/ | """ - .trimMargin()) + .trimMargin() + ) } } diff --git a/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/GitHubVariablesTest.kt b/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/GitHubVariablesTest.kt index 7d854ebd..d8948e15 100644 --- a/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/GitHubVariablesTest.kt +++ b/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/GitHubVariablesTest.kt @@ -30,10 +30,8 @@ class GitHubVariablesTest : GradleTestKitTest() { private fun GradleRunner.setEnvironmentVariables() { withEnvironment( - mapOf( - "GITHUB_ENV" to githubEnvFile.path, - "GITHUB_OUTPUT" to githubOutputFile.path, - )) + mapOf("GITHUB_ENV" to githubEnvFile.path, "GITHUB_OUTPUT" to githubOutputFile.path) + ) } @Test diff --git a/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/GradleFeaturesTest.kt b/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/GradleFeaturesTest.kt index bbeb7c0e..d194120a 100644 --- a/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/GradleFeaturesTest.kt +++ b/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/GradleFeaturesTest.kt @@ -74,7 +74,7 @@ class GradleFeaturesTest : GradleTestKitTest() { |v0.9.0+DIRTY | """ - .trimMargin(), + .trimMargin() ) projectDir.assertVersion("v", "0.9.0", Dirty) @@ -94,7 +94,7 @@ class GradleFeaturesTest : GradleTestKitTest() { |v0.9.1 | """ - .trimMargin(), + .trimMargin() ) git.add().addFilepattern(".").call() diff --git a/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/PushSemverTagTaskTest.kt b/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/PushSemverTagTaskTest.kt index 7800a427..6cd1ba34 100644 --- a/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/PushSemverTagTaskTest.kt +++ b/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/PushSemverTagTaskTest.kt @@ -29,7 +29,8 @@ class PushSemverTagTaskTest : GradleTestKitTest() { .setGitDir(remoteBuildGitDir) .readEnvironment() .findGitDir() - .build()) + .build() + ) git.repository.directory.copyRecursively(remoteBuildGitDir) diff --git a/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/VersionBuildDirTest.kt b/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/VersionBuildDirTest.kt index 6a0e5516..4065d485 100644 --- a/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/VersionBuildDirTest.kt +++ b/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/VersionBuildDirTest.kt @@ -59,7 +59,8 @@ internal class VersionBuildDirTest : GradleTestKitTest() { |v1.0.0$additionalData | """ - .trimMargin()) + .trimMargin() + ) } withArgumentsFromTXT() diff --git a/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/examples/MultiProjectExampleTest.kt b/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/examples/MultiProjectExampleTest.kt index 2dd10133..116d46af 100644 --- a/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/examples/MultiProjectExampleTest.kt +++ b/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/examples/MultiProjectExampleTest.kt @@ -227,7 +227,8 @@ internal class MultiProjectExampleTest : GradleTestKitTest() { "createSemverTag", "-Psemver.stage=final", "-Psemver.scope=major", - "-Psemver.tagPrefix=a") + "-Psemver.tagPrefix=a", + ) projectDirByName("library-one-a").assertVersion("a", "2.0.0") projectDirByName("library-two-b").assertVersion("b", "1.0.0", Insignificant.Hash) diff --git a/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/examples/OneProjectExampleTest.kt b/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/examples/OneProjectExampleTest.kt index a251c45e..688a5972 100644 --- a/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/examples/OneProjectExampleTest.kt +++ b/semver-project-gradle-plugin/testFunctional/kotlin/com/javiersc/semver/project/gradle/plugin/examples/OneProjectExampleTest.kt @@ -117,7 +117,8 @@ internal class OneProjectExampleTest : GradleTestKitTest() { "createSemverTag", "-Psemver.stage=final", "-Psemver.scope=major", - "-Psemver.tagPrefix=v") + "-Psemver.tagPrefix=v", + ) projectDir.assertVersion("v", "1.0.0") }