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) {
|
||||
|
|
|
@ -191,13 +191,16 @@ class PublishPlugin @Inject constructor(val files: KFiles, val factory: PomGener
|
|||
|
||||
data class GithubConfig(val project: Project) {
|
||||
val files = arrayListOf<File>()
|
||||
var autoGitTag = Triple(true, project.version!!, "")
|
||||
|
||||
/**
|
||||
* If true, automatically tag this release with the current version number and push that tag to origin when
|
||||
* the uploadGithub task is called.
|
||||
*/
|
||||
@Directive
|
||||
var autoGitTag: Boolean = false
|
||||
fun autoGitTag(auto: Boolean = autoGitTag.first, tag: String = project.version!!, message: String = autoGitTag.third) {
|
||||
autoGitTag = Triple(auto, tag, message)
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun file(filePath: String, url: String) {
|
||||
|
@ -213,6 +216,9 @@ fun Project.github(init: GithubConfig.() -> Unit): GithubConfig =
|
|||
}
|
||||
|
||||
data class BintrayConfig(val project: Project) {
|
||||
val files = arrayListOf<Pair<String, String>>()
|
||||
var autoGitTag = Triple(true, project.version!!, "")
|
||||
|
||||
/**
|
||||
* If true, the uploaded file will be published in your personal space (e.g. https://dl.bintray.com/cbeust/maven).
|
||||
* Once the file is uploaded there, it can be automatically synchronized to JCenter by linking your project to
|
||||
|
@ -233,9 +239,9 @@ data class BintrayConfig(val project: Project) {
|
|||
* the uploadBintray task is called.
|
||||
*/
|
||||
@Directive
|
||||
var autoGitTag: Boolean = true
|
||||
|
||||
val files = arrayListOf<Pair<String, String>>()
|
||||
fun autoGitTag(auto: Boolean = autoGitTag.first, tag: String = project.version!!, message: String = autoGitTag.third) {
|
||||
autoGitTag = Triple(auto, tag, message)
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun file(filePath: String, url: String) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue