mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Added parameters to autoGitTag directive.
This commit is contained in:
parent
99c447805e
commit
4f32f0ba2f
2 changed files with 17 additions and 10 deletions
|
@ -6,10 +6,10 @@ import com.google.inject.Inject
|
|||
import java.io.File
|
||||
|
||||
class Git @Inject constructor() {
|
||||
fun maybeTagRelease(project: Project, uploadResult: TaskResult, autoGitTag: Boolean) : TaskResult {
|
||||
fun maybeTagRelease(project: Project, uploadResult: TaskResult, autoGitTag: Triple<Boolean, String, String>) : TaskResult {
|
||||
val result =
|
||||
if (uploadResult.success && autoGitTag) {
|
||||
val tagSuccess = tagRelease(project)
|
||||
if (uploadResult.success && autoGitTag.first) {
|
||||
val tagSuccess = tagRelease(project, autoGitTag)
|
||||
if (! tagSuccess) {
|
||||
TaskResult(false, "Couldn't tag the project")
|
||||
} else {
|
||||
|
@ -21,16 +21,17 @@ class Git @Inject constructor() {
|
|||
return result
|
||||
}
|
||||
|
||||
private fun tagRelease(project: Project) : Boolean {
|
||||
private fun tagRelease(project: Project, autoGitTag: Triple<Boolean, String, String>) : Boolean {
|
||||
val success = try {
|
||||
log(2, "Tagging this release as \"${project.version}\"")
|
||||
val version = if (autoGitTag.second.isNullOrBlank()) project.version else autoGitTag.second
|
||||
log(2, "Tagging this release as \"$version\"")
|
||||
val repo = org.eclipse.jgit.storage.file.FileRepositoryBuilder()
|
||||
.setGitDir(File(KFiles.joinDir(project.directory, ".git")))
|
||||
.readEnvironment()
|
||||
.findGitDir()
|
||||
.build()
|
||||
val git = org.eclipse.jgit.api.Git(repo)
|
||||
val ref = git.tag().setName(project.version).call()
|
||||
val ref = git.tag().setName(version).setMessage(autoGitTag.third).call()
|
||||
git.push().setPushTags().call()
|
||||
true
|
||||
} catch(ex: Exception) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue