Skip to content

Commit

Permalink
allow overrideVersion to take effect even in detached head state if s…
Browse files Browse the repository at this point in the history
…pecified
  • Loading branch information
nefilim committed Apr 7, 2022
1 parent 6882459 commit f005b92
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ afterEvaluate {
}
}
}
signing.sign(publishing.publications)
val skipSigning = findProperty("skipSigning")?.let { (it as String).toBoolean() } ?: false
if (!skipSigning)
signing.sign(publishing.publications)
}

val githubTokenValue = findProperty("githubToken")?.toString() ?: System.getenv("GITHUB_TOKEN")
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/github/nefilim/gradle/semver/Git.kt
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ internal fun commitsSinceBranchPoint(
logger.semverWarn("failed to find any semver tags on branch [$branch], does main have any version tags? using 0 as commit count since branch point")
0
}, { youngestTag ->
logger.debug("youngest tag on this branch is at ${youngestTag.id.name} => ${tags[youngestTag.id]}")
logger.info("youngest tag on this branch is at ${youngestTag.id.name} => ${tags[youngestTag.id]}")
commits.takeWhile { it.id != youngestTag.id }.size
}).right()
}
Expand Down
25 changes: 12 additions & 13 deletions src/main/kotlin/io/github/nefilim/gradle/semver/SemVerExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,22 @@ abstract class SemVerExtension @Inject constructor(objects: ObjectFactory, priva
val ops = getGitContextProviderOperations(git, config)
val context = GradleSemVerContext(project, ops)

return ops.currentBranch().fold({
logger.error("failed to find current branch, cannot calculate semver".red())
throw Exception("failed to find current branch")
}, { currentBranch ->
logger.semver("current branch: $currentBranch")
val calculator = getTargetBranchVersionCalculator(ops, config, context, currentBranch)
logger.info("semver configuration while calculating version: $config")

config.overrideVersion.getOrElse {
return config.overrideVersion.getOrElse {
ops.currentBranch().fold({
logger.error("failed to find current branch, cannot calculate semver".red())
throw Exception("failed to find current branch")
}, { currentBranch ->
logger.semver("current branch: $currentBranch")
val calculator = getTargetBranchVersionCalculator(ops, config, context, currentBranch)
logger.info("semver configuration while calculating version: $config")
calculator.calculateVersion().getOrHandle {
logger.error("failed to calculate version: $it".red())
throw Exception("$it")
}
}.also {
logger.semver(it.toString())
}
})
})
}.also {
logger.semver(it.toString())
}
}
private fun versionTagName(): String = tagPrefix.map { "$it${version}" }.get()
private fun possiblyPrefixedVersion(version: String, prefix: String): SemVer {
Expand Down

0 comments on commit f005b92

Please sign in to comment.