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

Fix actionable action when uses latest sytanx version in lib #1817

Merged
merged 1 commit into from Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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