Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update all non-major dependencies (except core kotlin) #525

Merged
merged 4 commits into from
Apr 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

package com.saveourtool.save.buildutils

import org.ajoberstar.grgit.Grgit
import org.ajoberstar.grgit.gradle.GrgitServiceExtension
import org.ajoberstar.grgit.gradle.GrgitServicePlugin
import org.ajoberstar.reckon.core.Scope
import org.ajoberstar.reckon.core.VersionTagParser
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.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.getByType
import java.util.*

Check failure

Code scanning / ktlint

[FILE_WILDCARD_IMPORTS] wildcard imports should not be used: import java.util.* (cannot be auto-corrected) Error

[FILE_WILDCARD_IMPORTS] wildcard imports should not be used: import java.util.* (cannot be auto-corrected)

/**
* Configures how project version is determined.
Expand All @@ -23,36 +23,40 @@
*/
fun Project.configureVersioning() {
apply<ReckonPlugin>()
apply<GrgitServicePlugin>()
val grgitProvider = project.extensions
.getByType<GrgitServiceExtension>()
.service
.map { it.grgit }

val isSnapshot = hasProperty("reckon.stage") && property("reckon.stage") == "snapshot"
configure<ReckonExtension> {
scopeFromProp()
setDefaultInferredScope(Scope.MINOR.name)
setScopeCalc(calcScopeFromProp())
if (isSnapshot) {
// we should build snapshots only for snapshot publishing, so it requires explicit parameter
snapshotFromProp()
snapshots()
setStageCalc(calcStageFromProp())

/**

Check failure

Code scanning / ktlint

[COMMENTED_BY_KDOC] you should not comment inside code blocks using kdoc syntax: Redundant asterisk in block comment: ** Error

[COMMENTED_BY_KDOC] you should not comment inside code blocks using kdoc syntax: Redundant asterisk in block comment: \**

Check failure

Code scanning / ktlint

[WRONG_NEWLINES_AROUND_KDOC] there should be a blank line above the kDoc and there should not be no blank lines after kDoc: /**... Error

[WRONG_NEWLINES_AROUND_KDOC] there should be a blank line above the kDoc and there should not be no blank lines after kDoc: /**...
* A terrible hack to remove all pre-release tags. Because in semver `0.1.0-SNAPSHOT` < `0.1.0-alpha`, in snapshot mode
* we remove tags like `0.1.0-alpha`, and then reckoned version will still be `0.1.0-SNAPSHOT` and it will be compliant.
*/
setTagParser { tagName ->
nulls marked this conversation as resolved.
Show resolved Hide resolved
Optional.of(tagName)
.filter { it.matches(Regex("""^v\d+\.\d+\.\d+$""")) }
.flatMap { VersionTagParser.getDefault().parse(it) }
}
} else {
stageFromProp("alpha", "rc", "final")
stages("alpha", "rc", "final")
setStageCalc(calcStageFromProp())
}
}

// to activate release, provide `-Prelease` or `-Prelease=true`. To deactivate, either omit the property, or set `-Prelease=false`.
val isRelease = hasProperty("release") && (property("release") as String != "false")
if (isRelease) {
failOnUncleanTree(grgitProvider)
}
if (isSnapshot) {
fixForSnapshot(grgitProvider)
failOnUncleanTree()
}
}

private fun failOnUncleanTree(grgitProvider: Provider<Grgit>) {
val grgit = grgitProvider.get()
val status = grgit.repository.jgit
private fun Project.failOnUncleanTree() {
val status = Git(FileRepository(project.rootDir))
.status()
.call()
if (!status.isClean) {
Expand All @@ -61,18 +65,3 @@
}
}

/**
* A terrible hack to remove all pre-release tags. Because in semver `0.1.0-SNAPSHOT` < `0.1.0-alpha`, in snapshot mode
* we remove tags like `0.1.0-alpha`, and then reckoned version will still be `0.1.0-SNAPSHOT` and it will be compliant.
*/
private fun fixForSnapshot(grgitProvider: Provider<Grgit>) {
val grgit = grgitProvider.get()
val preReleaseTagNames = grgit.tag.list()
.sortedByDescending { it.commit.dateTime }
.takeWhile {
// take latest tags that are pre-release
!it.name.matches(Regex("""^v\d+\.\d+\.\d+$"""))
}
.map { it.name }
grgit.tag.remove { this.names = preReleaseTagNames }
}