mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-24 23:47:11 -07:00
Merge pull request #444 from ethauvin/master
Added push parameter to autoGitTag
This commit is contained in:
commit
4efe8125d7
2 changed files with 11 additions and 5 deletions
|
@ -6,10 +6,11 @@ import com.google.inject.Inject
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class Git @Inject constructor() {
|
class Git @Inject constructor() {
|
||||||
fun maybeTagRelease(project: Project, uploadResult: TaskResult, enabled: Boolean, annotated: Boolean, tag: String, message: String) : TaskResult {
|
fun maybeTagRelease(project: Project, uploadResult: TaskResult, enabled: Boolean, annotated: Boolean,
|
||||||
|
push: Boolean, tag: String, message: String) : TaskResult {
|
||||||
val result =
|
val result =
|
||||||
if (uploadResult.success && enabled) {
|
if (uploadResult.success && enabled) {
|
||||||
val tagSuccess = tagRelease(project, annotated, tag, message)
|
val tagSuccess = tagRelease(project, annotated, push, tag, message)
|
||||||
if (! tagSuccess) {
|
if (! tagSuccess) {
|
||||||
TaskResult(false, errorMessage = "Couldn't tag the project")
|
TaskResult(false, errorMessage = "Couldn't tag the project")
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,7 +22,7 @@ class Git @Inject constructor() {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tagRelease(project: Project, annotated: Boolean, tag: String, message: String) : Boolean {
|
private fun tagRelease(project: Project, annotated: Boolean, push: Boolean, tag: String, message: String) : Boolean {
|
||||||
val version = if (tag.isNullOrBlank()) project.version else tag
|
val version = if (tag.isNullOrBlank()) project.version else tag
|
||||||
val success = try {
|
val success = try {
|
||||||
log(2, "Tagging this release as \"$version\"")
|
log(2, "Tagging this release as \"$version\"")
|
||||||
|
@ -37,7 +38,9 @@ class Git @Inject constructor() {
|
||||||
} else {
|
} else {
|
||||||
git.tag().setName(version).setMessage(message).call()
|
git.tag().setName(version).setMessage(message).call()
|
||||||
}
|
}
|
||||||
git.push().setPushTags().call()
|
if (push) {
|
||||||
|
git.push().setPushTags().call()
|
||||||
|
}
|
||||||
true
|
true
|
||||||
} catch(ex: Exception) {
|
} catch(ex: Exception) {
|
||||||
warn("Couldn't create tag ${version}: ${ex.message}", ex)
|
warn("Couldn't create tag ${version}: ${ex.message}", ex)
|
||||||
|
|
|
@ -47,7 +47,7 @@ class PublishPlugin @Inject constructor(val files: KFiles, val factory: PomGener
|
||||||
private fun autoGitTag(project: Project, uploadResult: TaskResult, config: AutoGitTagConfig?) : TaskResult {
|
private fun autoGitTag(project: Project, uploadResult: TaskResult, config: AutoGitTagConfig?) : TaskResult {
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
with(config) {
|
with(config) {
|
||||||
return git.maybeTagRelease(project, uploadResult, enabled, annotated, tag, message)
|
return git.maybeTagRelease(project, uploadResult, enabled, annotated, push, tag, message)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return TaskResult()
|
return TaskResult()
|
||||||
|
@ -222,6 +222,9 @@ data class AutoGitTagConfig(val project: Project) {
|
||||||
@Directive
|
@Directive
|
||||||
var annotated: Boolean = false
|
var annotated: Boolean = false
|
||||||
|
|
||||||
|
@Directive
|
||||||
|
var push: Boolean = true
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
var tag : String = project.version!!
|
var tag : String = project.version!!
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue