PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: scala-steward-org/scala-steward (scala)

Issue:
Prevent updates from "normal" versions to hashes
See #2359 and https://github.com/scalameta/metals-gitpod-sample/pull/85 for example.

bloop-config and sbt-bloop are example artifacts that have a few hash versions:
* https://repo1.maven.org/maven2/ch/epfl/scala/bloop-config_2.12/
* https://repo1.maven.org/maven2/ch/epfl/scala/sbt-bloop_2.12_1.0/

Pull request:
@fthomas do you think this is too drastic

Fixes #2483

Patch:
diff --git a/modules/core/src/main/scala/org/scalasteward/core/data/Version.scala b/modules/core/src/main/scala/org/scalasteward/core/data/Version.scala
index 2ff42a0d89..2289fdc9e0 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/data/Version.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/data/Version.scala
@@ -21,6 +21,7 @@ import cats.implicits._
 import cats.parse.{Numbers, Parser, Rfc5234}
 import io.circe.Codec
 import io.circe.generic.extras.semiauto.deriveUnwrappedCodec
+import org.scalasteward.core.data.Version.startsWithDate
 
 final case class Version(value: String) {
   override def toString: String = value
@@ -62,6 +63,7 @@ final case class Version(value: String) {
           v.alnumComponents === alnumComponents ||
           // Do not select a version with hash if this version contains no hash.
           (v.containsHash && !containsHash) ||
+          (v.isOnlyHash && !isOnlyHash) ||
           // Don't select "versions" like %5BWARNING%5D.
           !v.startsWithLetterOrDigit
         }.sorted
@@ -69,6 +71,9 @@ final case class Version(value: String) {
       .lastOption
   }
 
+  private def isOnlyHash: Boolean =
+    Rfc5234.hexdig.rep(8).string.filterNot(startsWithDate).parseAll(value).isRight
+
   private def startsWithLetterOrDigit: Boolean =
     components.headOption.forall {
       case _: Version.Component.Numeric => true


Test patch:
diff --git a/modules/core/src/test/scala/org/scalasteward/core/data/VersionTest.scala b/modules/core/src/test/scala/org/scalasteward/core/data/VersionTest.scala
index 477e64b8d7..ec715cc76e 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/data/VersionTest.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/data/VersionTest.scala
@@ -216,7 +216,11 @@ class VersionTest extends DisciplineSuite {
       ("0.27.0-RC1", List("0.27.0-bin-20200826-2e58a66-NIGHTLY"), None),
       ("2.0.16-200-ge888c6dea", List("2.0.16-200-ge888c6dea-14-c067d59f0-SNAPSHOT"), None),
       ("17.0.0.1", List("18-ea+4"), None),
-      ("", List("", ".", "1", "a"), Some("1"))
+      ("", List("", ".", "1", "a"), Some("1")),
+      ("1.4.12", List("1032048a", "1032048a4c2"), None),
+      ("1.1", List("20000000"), None),
+      ("10000000", List("20000000"), Some("20000000")),
+      ("1032048a", List("2032048a4c2"), Some("2032048a4c2"))
     )
 
     val rnd = new Random()