Repository: scala-steward-org/scala-steward
Pull request #2362 (2021-11-17 15:27:23)

Move UpdatePattern.Version to VersionPattern
... and document the `exact` field.


Patch:
diff --git a/docs/repo-specific-configuration.md b/docs/repo-specific-configuration.md
index 943369c2..1278e46b 100644
--- a/docs/repo-specific-configuration.md
+++ b/docs/repo-specific-configuration.md
@@ -88,13 +88,17 @@ buildRoots = [ ".", "subfolder/projectA" ]
 
 The version information given in the patterns above can be in two formats:
 1. just a `version` field that is treated as a prefix of the version
-2. a structure consisting of `prefix` and / or `suffix` that are matched against the beginning or the end of the version
+2. a structure consisting of any of the following fields:
+   * `prefix`: is matched against the beginning of the version
+   * `suffix`: is matched against the end of the version
+   * `exact`: is matched against the whole version
 
 ```properties
 version = "1.1."
 version = { prefix = "1.1." }
 version = { suffix = "jre8" }
 version = { prefix = "1.1.", suffix = "jre8" }
+version = { exact = "1.1.2.jre8" }
 ```
 
 ## Ignore lines
diff --git a/docs/running.md b/docs/running.md
index 30932b5c..5519b270 100644
--- a/docs/running.md
+++ b/docs/running.md
@@ -8,7 +8,7 @@ sbt stage
 ./modules/core/.jvm/target/universal/stage/bin/scala-steward \
   --workspace  "$STEWARD_DIR/workspace" \
   --repos-file "$STEWARD_DIR/repos.md" \
-  --repo-config "$STEWARD_DIR/default.scala-steward.conf" \
+  --default-repo-conf "$STEWARD_DIR/default.scala-steward.conf" \
   --git-author-email ${EMAIL} \
   --vcs-api-host "https://api.github.com" \
   --vcs-login ${LOGIN} \
@@ -25,7 +25,7 @@ sbt docker:publishLocal
 docker run -v $STEWARD_DIR:/opt/scala-steward -it fthomas/scala-steward:latest \
   --workspace  "/opt/scala-steward/workspace" \
   --repos-file "/opt/scala-steward/repos.md" \
-  --repo-config "/opt/scala-steward/default.scala-steward.conf" \
+  --default-repo-conf "/opt/scala-steward/default.scala-steward.conf" \
   --git-author-email ${EMAIL} \
   --vcs-api-host "https://api.github.com" \
   --vcs-login ${LOGIN} \
@@ -90,7 +90,7 @@ example1.realm=Example Realm
 ```
 sbt
 project core
-run --do-not-fork --workspace "/path/workspace" --repos-file "/path/repos.md" --repo-config "/path/default.scala-steward.conf" --git-ask-pass "/path/pass.sh" --git-author-email "email@example.org" --vcs-type "gitlab" --vcs-api-host "https://gitlab.com/api/v4/" --vcs-login "gitlab.steward"
+run --do-not-fork --workspace "/path/workspace" --repos-file "/path/repos.md" --default-repo-conf "/path/default.scala-steward.conf" --git-ask-pass "/path/pass.sh" --git-author-email "email@example.org" --vcs-type "gitlab" --vcs-api-host "https://gitlab.com/api/v4/" --vcs-login "gitlab.steward"
 ```
 
 
@@ -112,7 +112,7 @@ docker run -v $PWD:/opt/scala-steward \
     --do-not-fork \
     --workspace "/opt/scala-steward/workspace" \
     --repos-file "/opt/scala-steward/repos.md" \
-    --repo-config "/opt/scala-steward/default.scala-steward.conf" \
+    --default-repo-conf "/opt/scala-steward/default.scala-steward.conf" \
     --git-ask-pass "/opt/scala-steward/pass.sh" \
     --git-author-email "myemail@company.xyz" \
     --vcs-type "bitbucket" \
@@ -141,7 +141,7 @@ docker run -v $PWD:/opt/scala-steward \
     --do-not-fork \
     --workspace "/opt/scala-steward/workspace" \
     --repos-file "/opt/scala-steward/repos.md" \
-    --repo-config "/opt/scala-steward/default.scala-steward.conf" \
+    --default-repo-conf "/opt/scala-steward/default.scala-steward.conf" \
     --git-ask-pass "/opt/scala-steward/pass.sh" \
     --git-author-email "myemail@company.xyz" \
     --vcs-type "bitbucket" \
@@ -236,7 +236,7 @@ check:
         --process-timeout 30min
         --do-not-fork
         --repos-file "$CI_PROJECT_DIR/repos.md"
-        --repo-config "$CI_PROJECT_DIR/default.scala-steward.conf"
+        --default-repo-conf "$CI_PROJECT_DIR/default.scala-steward.conf"
         --git-author-email "${EMAIL}"
         --vcs-type "gitlab"
         --vcs-api-host "${CI_API_V4_URL}"
diff --git a/modules/benchmark/src/main/scala/org/scalasteward/benchmark/UpdatesConfigBenchmark.scala b/modules/benchmark/src/main/scala/org/scalasteward/benchmark/UpdatesConfigBenchmark.scala
index 2b20e8a5..f881a048 100644
--- a/modules/benchmark/src/main/scala/org/scalasteward/benchmark/UpdatesConfigBenchmark.scala
+++ b/modules/benchmark/src/main/scala/org/scalasteward/benchmark/UpdatesConfigBenchmark.scala
@@ -19,7 +19,7 @@ package org.scalasteward.benchmark
 import java.util.concurrent.TimeUnit
 import org.openjdk.jmh.annotations.{Benchmark, BenchmarkMode, Mode, OutputTimeUnit}
 import org.scalasteward.core.data._
-import org.scalasteward.core.repoconfig.{UpdatePattern, UpdatesConfig}
+import org.scalasteward.core.repoconfig.{UpdatePattern, UpdatesConfig, VersionPattern}
 import org.scalasteward.core.util.Nel
 
 @BenchmarkMode(Array(Mode.AverageTime))
@@ -37,7 +37,7 @@ class UpdatesConfigBenchmark {
     UpdatesConfig().keep(update)
     UpdatesConfig(allow = List(UpdatePattern(groupId, None, None))).keep(update)
     UpdatesConfig(allow =
-      List(UpdatePattern(groupId, None, Some(UpdatePattern.Version(prefix = Some("6.0")))))
+      List(UpdatePattern(groupId, None, Some(VersionPattern(prefix = Some("6.0")))))
     ).keep(update)
   }
 }
diff --git a/modules/core/src/main/scala/org/scalasteward/core/repoconfig/UpdatePattern.scala b/modules/core/src/main/scala/org/scalasteward/core/repoconfig/UpdatePattern.scala
index 12627c6f..8d996df2 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/repoconfig/UpdatePattern.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/repoconfig/UpdatePattern.scala
@@ -16,16 +16,15 @@
 
 package org.scalasteward.core.repoconfig
 
-import cats.Eq
-import cats.implicits._
+import cats.syntax.all._
+import io.circe.Codec
 import io.circe.generic.semiauto._
-import io.circe.{Codec, Decoder, Encoder}
 import org.scalasteward.core.data.{GroupId, Update}
 
 final case class UpdatePattern(
     groupId: GroupId,
     artifactId: Option[String],
-    version: Option[UpdatePattern.Version]
+    version: Option[VersionPattern]
 ) {
   def isWholeGroupIdAllowed: Boolean = artifactId.isEmpty && version.isEmpty
 }
@@ -36,17 +35,6 @@ object UpdatePattern {
       filteredVersions: List[String]
   )
 
-  final case class Version(
-      prefix: Option[String] = None,
-      suffix: Option[String] = None,
-      exact: Option[String] = None
-  ) {
-    def matches(version: String): Boolean =
-      prefix.forall(version.startsWith) &&
-        suffix.forall(version.endsWith) &&
-        exact.forall(_ === version)
-  }
-
   def findMatch(
       patterns: List[UpdatePattern],
       update: Update.Single,
@@ -62,13 +50,4 @@ object UpdatePattern {
 
   implicit val updatePatternCodec: Codec[UpdatePattern] =
     deriveCodec
-
-  implicit val updatePatternVersionEq: Eq[Version] =
-    Eq.fromUniversalEquals
-
-  implicit val updatePatternVersionDecoder: Decoder[Version] =
-    deriveDecoder[Version].or(Decoder[String].map(s => Version(prefix = Some(s))))
-
-  implicit val updatePatternVersionEncoder: Encoder[Version] =
-    deriveEncoder
 }
diff --git a/modules/core/src/main/scala/org/scalasteward/core/repoconfig/VersionPattern.scala b/modules/core/src/main/scala/org/scalasteward/core/repoconfig/VersionPattern.scala
new file mode 100644
index 00000000..26f19a0b
--- /dev/null
+++ b/modules/core/src/main/scala/org/scalasteward/core/repoconfig/VersionPattern.scala
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2018-2021 Scala Steward contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.scalasteward.core.repoconfig
+
+import cats.Eq
+import cats.syntax.all._
+import io.circe.generic.semiauto._
+import io.circe.{Decoder, Encoder}
+
+final case class VersionPattern(
+    prefix: Option[String] = None,
+    suffix: Option[String] = None,
+    exact: Option[String] = None
+) {
+  def matches(version: String): Boolean =
+    prefix.forall(version.startsWith) &&
+      suffix.forall(version.endsWith) &&
+      exact.forall(_ === version)
+}
+
+object VersionPattern {
+  implicit val versionPatternEq: Eq[VersionPattern] =
+    Eq.fromUniversalEquals
+
+  implicit val versionPatternDecoder: Decoder[VersionPattern] =
+    deriveDecoder[VersionPattern].or(Decoder[String].map(s => VersionPattern(prefix = Some(s))))
+
+  implicit val versionPatternEncoder: Encoder[VersionPattern] =
+    deriveEncoder
+}
diff --git a/modules/docs/mdoc/running.md b/modules/docs/mdoc/running.md
index 9c44fffc..f03a1034 100644
--- a/modules/docs/mdoc/running.md
+++ b/modules/docs/mdoc/running.md
@@ -8,7 +8,7 @@ sbt stage
 ./modules/core/.jvm/target/universal/stage/bin/scala-steward \
   --workspace  "$STEWARD_DIR/workspace" \
   --repos-file "$STEWARD_DIR/repos.md" \
-  --repo-config "$STEWARD_DIR/default.scala-steward.conf" \
+  --default-repo-conf "$STEWARD_DIR/default.scala-steward.conf" \
   --git-author-email ${EMAIL} \
   --vcs-api-host "https://api.github.com" \
   --vcs-login ${LOGIN} \
@@ -25,7 +25,7 @@ sbt docker:publishLocal
 docker run -v $STEWARD_DIR:/opt/scala-steward -it fthomas/scala-steward:latest \
   --workspace  "/opt/scala-steward/workspace" \
   --repos-file "/opt/scala-steward/repos.md" \
-  --repo-config "/opt/scala-steward/default.scala-steward.conf" \
+  --default-repo-conf "/opt/scala-steward/default.scala-steward.conf" \
   --git-author-email ${EMAIL} \
   --vcs-api-host "https://api.github.com" \
   --vcs-login ${LOGIN} \
@@ -90,7 +90,7 @@ example1.realm=Example Realm
 ```
 sbt
 project core
-run --do-not-fork --workspace "/path/workspace" --repos-file "/path/repos.md" --repo-config "/path/default.scala-steward.conf" --git-ask-pass "/path/pass.sh" --git-author-email "email@example.org" --vcs-type "gitlab" --vcs-api-host "https://gitlab.com/api/v4/" --vcs-login "gitlab.steward"
+run --do-not-fork --workspace "/path/workspace" --repos-file "/path/repos.md" --default-repo-conf "/path/default.scala-steward.conf" --git-ask-pass "/path/pass.sh" --git-author-email "email@example.org" --vcs-type "gitlab" --vcs-api-host "https://gitlab.com/api/v4/" --vcs-login "gitlab.steward"
 ```
 
 
@@ -112,7 +112,7 @@ docker run -v $PWD:/opt/scala-steward \
     --do-not-fork \
     --workspace "/opt/scala-steward/workspace" \
     --repos-file "/opt/scala-steward/repos.md" \
-    --repo-config "/opt/scala-steward/default.scala-steward.conf" \
+    --default-repo-conf "/opt/scala-steward/default.scala-steward.conf" \
     --git-ask-pass "/opt/scala-steward/pass.sh" \
     --git-author-email "myemail@company.xyz" \
     --vcs-type "bitbucket" \
@@ -141,7 +141,7 @@ docker run -v $PWD:/opt/scala-steward \
     --do-not-fork \
     --workspace "/opt/scala-steward/workspace" \
     --repos-file "/opt/scala-steward/repos.md" \
-    --repo-config "/opt/scala-steward/default.scala-steward.conf" \
+    --default-repo-conf "/opt/scala-steward/default.scala-steward.conf" \
     --git-ask-pass "/opt/scala-steward/pass.sh" \
     --git-author-email "myemail@company.xyz" \
     --vcs-type "bitbucket" \
@@ -236,7 +236,7 @@ check:
         --process-timeout 30min
         --do-not-fork
         --repos-file "$CI_PROJECT_DIR/repos.md"
-        --repo-config "$CI_PROJECT_DIR/default.scala-steward.conf"
+        --default-repo-conf "$CI_PROJECT_DIR/default.scala-steward.conf"
         --git-author-email "${EMAIL}"
         --vcs-type "gitlab"
         --vcs-api-host "${CI_API_V4_URL}"
diff --git a/project/plugins.sbt b/project/plugins.sbt
index deb84438..97ba76e8 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -5,7 +5,7 @@ addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
 addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3")
 addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16")
 addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.9.9")
-addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.7")
+addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.6")
 addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
 addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20")
 addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")


Test patch:
diff --git a/modules/core/src/test/scala/org/scalasteward/core/TestInstances.scala b/modules/core/src/test/scala/org/scalasteward/core/TestInstances.scala
index b6c96c3a..a94a2c1e 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/TestInstances.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/TestInstances.scala
@@ -130,7 +130,7 @@ object TestInstances {
       artifactId <- Arbitrary.arbitrary[Option[String]]
       version <- Arbitrary
         .arbitrary[Option[String]]
-        .map(_.map(prefix => UpdatePattern.Version(prefix = Some(prefix))))
+        .map(_.map(prefix => VersionPattern(prefix = Some(prefix))))
     } yield UpdatePattern(groupId = groupId, artifactId = artifactId, version = version))
 
   private def smallListOf[A](maxSize: Int, genA: Gen[A]): Gen[List[A]] =
diff --git a/modules/core/src/test/scala/org/scalasteward/core/repoconfig/RepoConfigAlgTest.scala b/modules/core/src/test/scala/org/scalasteward/core/repoconfig/RepoConfigAlgTest.scala
index a3397bff..0211e287 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/repoconfig/RepoConfigAlgTest.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/repoconfig/RepoConfigAlgTest.scala
@@ -57,26 +57,26 @@ class RepoConfigAlgTest extends FunSuite {
           UpdatePattern(
             GroupId("eu.timepit"),
             Some("refined.1"),
-            Some(UpdatePattern.Version(Some("0.8.")))
+            Some(VersionPattern(Some("0.8.")))
           ),
           UpdatePattern(
             GroupId("eu.timepit"),
             Some("refined.2"),
-            Some(UpdatePattern.Version(Some("0.8.")))
+            Some(VersionPattern(Some("0.8.")))
           ),
           UpdatePattern(
             GroupId("eu.timepit"),
             Some("refined.3"),
-            Some(UpdatePattern.Version(suffix = Some("jre")))
+            Some(VersionPattern(suffix = Some("jre")))
           ),
           UpdatePattern(
             GroupId("eu.timepit"),
             Some("refined.4"),
-            Some(UpdatePattern.Version(Some("0.8."), Some("jre")))
+            Some(VersionPattern(Some("0.8."), Some("jre")))
           )
         ),
         ignore = List(
-          UpdatePattern(GroupId("org.acme"), None, Some(UpdatePattern.Version(Some("1.0"))))
+          UpdatePattern(GroupId("org.acme"), None, Some(VersionPattern(Some("1.0"))))
         ),
         limit = Some(NonNegInt.unsafeFrom(4)),
         fileExtensions = Some(List(".txt"))
diff --git a/modules/core/src/test/scala/org/scalasteward/core/repoconfig/UpdatesConfigTest.scala b/modules/core/src/test/scala/org/scalasteward/core/repoconfig/UpdatesConfigTest.scala
index a4802360..368e54bd 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/repoconfig/UpdatesConfigTest.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/repoconfig/UpdatesConfigTest.scala
@@ -4,7 +4,6 @@ import cats.kernel.laws.discipline.MonoidTests
 import munit.DisciplineSuite
 import org.scalasteward.core.TestInstances._
 import org.scalasteward.core.data.GroupId
-import org.scalasteward.core.repoconfig.UpdatePattern.Version
 
 class UpdatesConfigTest extends DisciplineSuite {
   checkAll("Monoid[UpdatesConfig]", MonoidTests[UpdatesConfig].monoid)
@@ -17,9 +16,9 @@ class UpdatesConfigTest extends DisciplineSuite {
   private val ab0 = UpdatePattern(groupIdA, Some("b"), None)
   private val ac0 = UpdatePattern(groupIdA, Some("c"), None)
 
-  private val aa1 = UpdatePattern(groupIdA, Some("a"), Some(Version(Some("1"))))
-  private val aa2 = UpdatePattern(groupIdA, Some("a"), Some(Version(Some("2"))))
-  private val ac3 = UpdatePattern(groupIdA, Some("c"), Some(Version(Some("3"))))
+  private val aa1 = UpdatePattern(groupIdA, Some("a"), Some(VersionPattern(Some("1"))))
+  private val aa2 = UpdatePattern(groupIdA, Some("a"), Some(VersionPattern(Some("2"))))
+  private val ac3 = UpdatePattern(groupIdA, Some("c"), Some(VersionPattern(Some("3"))))
 
   private val b00 = UpdatePattern(groupIdB, None, None)
 
diff --git a/modules/core/src/test/scala/org/scalasteward/core/update/FilterAlgTest.scala b/modules/core/src/test/scala/org/scalasteward/core/update/FilterAlgTest.scala
index 12128df6..1ed4bed9 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/update/FilterAlgTest.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/update/FilterAlgTest.scala
@@ -8,7 +8,7 @@ import org.scalasteward.core.data.{ArtifactId, Dependency, GroupId}
 import org.scalasteward.core.mock.MockContext.context.filterAlg
 import org.scalasteward.core.mock.MockState
 import org.scalasteward.core.mock.MockState.TraceEntry.Log
-import org.scalasteward.core.repoconfig.{RepoConfig, UpdatePattern, UpdatesConfig}
+import org.scalasteward.core.repoconfig.{RepoConfig, UpdatePattern, UpdatesConfig, VersionPattern}
 import org.scalasteward.core.update.FilterAlg._
 import org.scalasteward.core.util.Nel
 
@@ -77,7 +77,7 @@ class FilterAlgTest extends FunSuite {
           UpdatePattern(
             GroupId("org.scala-lang"),
             Some("scala-compiler"),
-            Some(UpdatePattern.Version(exact = Some("2.13.8")))
+            Some(VersionPattern(exact = Some("2.13.8")))
           )
         )
       )
@@ -93,11 +93,11 @@ class FilterAlgTest extends FunSuite {
     val config = RepoConfig(
       updates = UpdatesConfig(
         pin = List(
-          UpdatePattern(update1.groupId, None, Some(UpdatePattern.Version(Some("0.17")))),
+          UpdatePattern(update1.groupId, None, Some(VersionPattern(Some("0.17")))),
           UpdatePattern(
             update2.groupId,
             Some("refined"),
-            Some(UpdatePattern.Version(Some("0.8")))
+            Some(VersionPattern(Some("0.8")))
           )
         )
       )
@@ -126,7 +126,7 @@ class FilterAlgTest extends FunSuite {
     val config = RepoConfig(
       updates = UpdatesConfig(
         allow = List(
-          UpdatePattern(GroupId("org.my1"), None, Some(UpdatePattern.Version(Some("0.8")))),
+          UpdatePattern(GroupId("org.my1"), None, Some(VersionPattern(Some("0.8")))),
           UpdatePattern(GroupId("org.my2"), None, None),
           UpdatePattern(GroupId("org.my3"), Some("artifact"), None)
         )
@@ -153,7 +153,7 @@ class FilterAlgTest extends FunSuite {
           UpdatePattern(
             update.groupId,
             Some(update.artifactId.name),
-            Some(UpdatePattern.Version(suffix = Some("jre8")))
+            Some(VersionPattern(suffix = Some("jre8")))
           )
         )
       )
@@ -175,7 +175,7 @@ class FilterAlgTest extends FunSuite {
           UpdatePattern(
             update.groupId,
             Some(update.artifactId.name),
-            Some(UpdatePattern.Version(suffix = Some("jre11")))
+            Some(VersionPattern(suffix = Some("jre11")))
           )
         )
       )
@@ -197,7 +197,7 @@ class FilterAlgTest extends FunSuite {
           UpdatePattern(
             update.groupId,
             Some(update.artifactId.name),
-            Some(UpdatePattern.Version(Some("7.2."), Some("jre8")))
+            Some(VersionPattern(Some("7.2."), Some("jre8")))
           )
         )
       )