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

Ensure vague Scala versions are capped at defaults #3259

Merged
merged 2 commits into from
Nov 21, 2024

Conversation

Gedochao
Copy link
Contributor

@Gedochao Gedochao commented Nov 5, 2024

Fixes #3233

Note: this may potentially be a breaking change.

This changes how Scala version is picked whenmajor or major.minor prefixes are passed, rather than the full version tag:

Or, to give examples, with what is currently on sonatype:

  • -S 3
    • before
    scala-cli -with-compiler -e 'println(dotty.tools.dotc.config.Properties.versionNumberString)' -S 3
    # Compiling project (Scala 3.6.1, JVM (17))
    # Compiled project (Scala 3.6.1, JVM (17))
    # 3.6.1
    • after
    scala-cli -with-compiler -e 'println(dotty.tools.dotc.config.Properties.versionNumberString)' -S 3
    # Compiling project (Scala 3.5.2, JVM (17))
    # Compiled project (Scala 3.5.2, JVM (17))
    # 3.5.2
  • -S 3, when --cli-user-scala-version 3.6.0
    • before
    scala-cli --cli-user-scala-version 3.6.0 -with-compiler -e 'println(dotty.tools.dotc.config.Properties.versionNumberString)' -S 3
    # Compiling project (Scala 3.6.1, JVM (17))
    # Compiled project (Scala 3.6.1, JVM (17))
    # 3.6.1
    • after
    scala-cli --cli-user-scala-version 3.6.0 -with-compiler -e 'println(dotty.tools.dotc.config.Properties.versionNumberString)' -S 3
    # Compiling project (Scala 3.6.0, JVM (17))
    # Compiled project (Scala 3.6.0, JVM (17))
    # 3.6.0
  • -S 3.5
    • before
    scala-cli --cli-user-scala-version 3.5.1 -with-compiler -e 'println(dotty.tools.dotc.config.Properties.versionNumberString)' -S 3.5 
    # Compiling project (Scala 3.5.2, JVM (17))
    # Compiled project (Scala 3.5.2, JVM (17))
    # 3.5.2
    • after
    scala-cli --cli-user-scala-version 3.5.1 -with-compiler -e 'println(dotty.tools.dotc.config.Properties.versionNumberString)' -S 3.5 
    # Compiling project (Scala 3.5.1, JVM (17))
    # Compiled project (Scala 3.5.1, JVM (17))
    # 3.5.1

For more examples, refer to the test suite cases.

The purpose of this change is to safeguard against future incidents similar to the Scala 3.6.0 mis-release. When a new Scala version is released on sonatype, Scala CLI will no longer pick it up automatically with vague version tags (such as -S 3). Of course, any version remains usable when the entire version string is passed (so -S 3.6.1 remains valid for any launcher).

The downside of this change is that the meaning of a vague version string will change on scala-cli launcher upgrade.

@Gedochao Gedochao force-pushed the fix/soft-cap-scala-version branch 2 times, most recently from 17b0eaa to a74250d Compare November 5, 2024 13:35
@Gedochao Gedochao added the needs-minor-release This change should require a minor version bump. label Nov 5, 2024
@Gedochao Gedochao marked this pull request as ready for review November 5, 2024 15:28
@Gedochao Gedochao requested a review from tgodzik November 5, 2024 15:28
@tgodzik
Copy link
Member

tgodzik commented Nov 5, 2024

I wonder should the other option be to check if https://github.com/scala/scala3/releases/tag/${scalaVersion} exists?

@Gedochao
Copy link
Contributor Author

Gedochao commented Nov 6, 2024

I wonder should the other option be to check if https://github.com/scala/scala3/releases/tag/${scalaVersion} exists?

It does exist for 3.6.1, though...

@SethTisue
Copy link
Contributor

👏

@Gedochao Gedochao enabled auto-merge (squash) November 21, 2024 08:17
@Gedochao Gedochao merged commit e317435 into VirtusLab:main Nov 21, 2024
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-minor-release This change should require a minor version bump.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a way to only move to newer versions of Scala after approval
3 participants