Skip to content

Commit

Permalink
Fix toolkit dependency updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Gedochao committed May 23, 2023
1 parent 043f7ed commit 094c295
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Expand Up @@ -61,7 +61,7 @@ class DependencyUpdateTests extends ScalaCliSuite {
}
}

test("update typelevel toolkit dependence") {
test("update typelevel toolkit dependency") {
val toolkitVersion = "0.0.1"
val testInputs = TestInputs(
os.rel / "Foo.scala" ->
Expand All @@ -79,7 +79,7 @@ class DependencyUpdateTests extends ScalaCliSuite {
os.proc(TestUtil.cli, "--power", "dependency-update", "--all", ".")
.call(cwd = root)

val toolkitDirective = "//> using toolkit \"(.*)\"".r
val toolkitDirective = "//> using toolkit \"typelevel:(.*)\"".r
val updatedToolkitVersionOpt = {
val regexMatch = toolkitDirective.findFirstMatchIn(os.read(root / "Foo.scala"))
regexMatch.map(_.group(1))
Expand Down
Expand Up @@ -3,14 +3,15 @@ package scala.build.actionable
import coursier.Versions
import coursier.core.{Latest, Version}
import coursier.parse.RepositoryParser
import dependency._
import dependency.*

import scala.build.EitherCps.{either, value}
import scala.build.Positioned
import scala.build.actionable.ActionableDiagnostic._
import scala.build.actionable.ActionableDiagnostic.*
import scala.build.actionable.errors.ActionableHandlerError
import scala.build.errors.{BuildException, RepositoryFormatError}
import scala.build.internal.Util._
import scala.build.internal.Constants
import scala.build.internal.Util.*
import scala.build.options.BuildOptions
import scala.build.options.ScalaVersionUtil.versions
import scala.concurrent.duration.DurationInt
Expand All @@ -32,15 +33,26 @@ case object ActionableDependencyHandler
val dependency = setting.value
val currentVersion = dependency.version
val latestVersion = value(findLatestVersion(buildOptions, dependency))
if (Version(latestVersion) > Version(currentVersion) && !isLatestSyntaxVersion(currentVersion))
if (dependency.userParams.contains("toolkit"))
if Version(latestVersion) > Version(currentVersion) && !isLatestSyntaxVersion(currentVersion)
then
if dependency.userParams.contains(Constants.toolkitName) &&
dependency.module.name != Constants.toolkitTestName
then
val toolkitSuggestion =
if dependency.module.organization == Constants.toolkitOrganization then latestVersion
else if dependency.module.organization == Constants.typelevelOrganization then
s"typelevel:$latestVersion"
else s"${dependency.module.organization}:$latestVersion"
Some(ActionableDependencyUpdateDiagnostic(
setting.positions,
currentVersion,
latestVersion,
dependencyModuleName = "toolkit",
suggestion = latestVersion
dependencyModuleName = Constants.toolkitName,
suggestion = toolkitSuggestion
))
else if dependency.userParams.contains(Constants.toolkitName) &&
dependency.module.name == Constants.toolkitTestName
then None // filtering out toolkit-test to prevent double-update-diagnostic
else
Some(ActionableDependencyUpdateDiagnostic(
setting.positions,
Expand Down

0 comments on commit 094c295

Please sign in to comment.