Skip to content

Commit

Permalink
supported changes from new reckon plugin version
Browse files Browse the repository at this point in the history
  • Loading branch information
nulls committed May 2, 2023
1 parent 049e5d4 commit 1a8bc65
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,38 @@

package org.cqfn.diktat.buildutils

import org.ajoberstar.grgit.gradle.GrgitServiceExtension
import org.ajoberstar.grgit.gradle.GrgitServicePlugin
import org.ajoberstar.reckon.core.Scope
import org.ajoberstar.reckon.gradle.ReckonExtension
import org.ajoberstar.reckon.gradle.ReckonPlugin
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.internal.storage.file.FileRepository
import org.eclipse.jgit.storage.file.FileRepositoryBuilder
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.getByType

/**
* Configures reckon plugin for [this] project, should be applied for root project only
*/
fun Project.configureVersioning() {
apply<ReckonPlugin>()
apply<GrgitServicePlugin>()

// should be provided in the gradle.properties
configure<ReckonExtension> {
setDefaultInferredScope(Scope.MINOR.name)
snapshots()
setScopeCalc(calcScopeFromProp())
setStageCalc(calcStageFromProp())
}

val status = project.extensions.getByType<GrgitServiceExtension>()
.service
.map { it.grgit.repository.jgit.status().call() }
.get()
val status = FileRepositoryBuilder()
.findGitDir(project.rootDir)
.setup()
.let(::FileRepository)
.let(::Git)
.status()
.call()

if (!status.isClean) {
logger.warn("git tree is not clean; " +
"Untracked files: ${status.untracked}, uncommitted changes: ${status.uncommittedChanges}"
Expand Down

0 comments on commit 1a8bc65

Please sign in to comment.