Skip to content

Commit

Permalink
Fix actionable action when uses latest sytanx version in lib (VirtusL…
Browse files Browse the repository at this point in the history
  • Loading branch information
lwronski authored and tgodzik committed Feb 13, 2023
1 parent eff9ac1 commit fee8f46
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Expand Up @@ -208,7 +208,30 @@ class ActionableDiagnosticTests extends munit.FunSuite {
val testLibDiagnosticOpt = updateDiagnostics.collectFirst {
case diagnostic: ActionableDependencyUpdateDiagnostic => diagnostic
}
println(testLibDiagnosticOpt)
expect(testLibDiagnosticOpt.isEmpty)
}
}

test("actionable actions should not suggest update if uses version: latest") {
val testInputs = TestInputs(
os.rel / "Foo.scala" ->
s"""//> using toolkit "latest"
|
|object Hello extends App {
| os.list(os.pwd).foreach(println)
|}
|""".stripMargin
)
testInputs.withBuild(baseOptions, buildThreads, None, actionableDiagnostics = true) {
(_, _, maybeBuild) =>
val build = maybeBuild.orThrow

val updateDiagnostics =
ActionablePreprocessor.generateActionableDiagnostics(build.options).orThrow

val testLibDiagnosticOpt = updateDiagnostics.collectFirst {
case diagnostic: ActionableDependencyUpdateDiagnostic => diagnostic
}
expect(testLibDiagnosticOpt.isEmpty)
}
}
Expand Down
@@ -1,7 +1,7 @@
package scala.build.actionable

import coursier.Versions
import coursier.core.Version
import coursier.core.{Latest, Version}
import coursier.parse.RepositoryParser
import dependency._

Expand Down Expand Up @@ -29,8 +29,7 @@ case object ActionableDependencyHandler
val dependency = setting.value
val currentVersion = dependency.version
val latestVersion = value(findLatestVersion(buildOptions, dependency))

if (Version(latestVersion) > Version(currentVersion))
if (Version(latestVersion) > Version(currentVersion) && !isLatestSyntaxVersion(currentVersion))
if (dependency.userParams.contains("toolkit"))
Some(ActionableDependencyUpdateDiagnostic(
setting.positions,
Expand All @@ -51,6 +50,9 @@ case object ActionableDependencyHandler
None
}

/** Versions like 'latest.*': 'latest.release', 'latest.integration', 'latest.stable'
*/
private def isLatestSyntaxVersion(version: String): Boolean = Latest(version).nonEmpty
private def findLatestVersion(
buildOptions: BuildOptions,
dependency: AnyDependency
Expand Down

0 comments on commit fee8f46

Please sign in to comment.