Repository: scala-steward-org/scala-steward
Pull request #1916 (2021-02-01 21:14:39)

Rename SupportedVCS to VCSType


Patch:
diff --git a/modules/core/src/main/scala/org/scalasteward/core/application/Cli.scala b/modules/core/src/main/scala/org/scalasteward/core/application/Cli.scala
index a1bd28e9..98f2c747 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/application/Cli.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/application/Cli.scala
@@ -24,6 +24,7 @@ import cats.syntax.all._
 import org.http4s.Uri
 import org.http4s.syntax.literals._
 import org.scalasteward.core.util.dateTime.parseFiniteDuration
+import org.scalasteward.core.vcs.VCSType
 import scala.concurrent.duration._
 
 object Cli {
@@ -34,7 +35,7 @@ object Cli {
       gitAuthorName: String = "Scala Steward",
       gitAuthorEmail: String,
       gitAuthorSigningKey: Option[String] = None,
-      vcsType: SupportedVCS = SupportedVCS.GitHub,
+      vcsType: VCSType = VCSType.GitHub,
       vcsApiHost: Uri = uri"https://api.github.com",
       vcsLogin: String,
       gitAskPass: File,
@@ -109,10 +110,10 @@ object Cli {
         }
     )
 
-  implicit val supportedVCSArgParser: ArgParser[SupportedVCS] =
+  implicit val vcsTypeArgParser: ArgParser[VCSType] =
     ArgParser[String].xmapError(
       _.asString,
-      s => SupportedVCS.parse(s).leftMap(error => MalformedValue("SupportedVCS", error))
+      s => VCSType.parse(s).leftMap(error => MalformedValue("VCSType", error))
     )
 
   implicit val uriArgParser: ArgParser[Uri] =
diff --git a/modules/core/src/main/scala/org/scalasteward/core/application/Config.scala b/modules/core/src/main/scala/org/scalasteward/core/application/Config.scala
index b43a05c8..36bf9b61 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/application/Config.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/application/Config.scala
@@ -27,6 +27,7 @@ import org.scalasteward.core.git.Author
 import org.scalasteward.core.io.{ProcessAlg, WorkspaceAlg}
 import org.scalasteward.core.util
 import org.scalasteward.core.util.Nel
+import org.scalasteward.core.vcs.VCSType
 import org.scalasteward.core.vcs.data.AuthenticatedUser
 import org.scalasteward.core.vcs.github.GitHubApp
 import scala.concurrent.duration.FiniteDuration
@@ -60,7 +61,7 @@ final case class Config(
     reposFile: File,
     defaultRepoConfigFile: Option[File],
     gitCfg: GitCfg,
-    vcsType: SupportedVCS,
+    vcsType: VCSType,
     vcsApiHost: Uri,
     vcsLogin: String,
     doNotFork: Boolean,
diff --git a/modules/core/src/main/scala/org/scalasteward/core/vcs/VCSSelection.scala b/modules/core/src/main/scala/org/scalasteward/core/vcs/VCSSelection.scala
index 74b1231a..444ece00 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/vcs/VCSSelection.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/vcs/VCSSelection.scala
@@ -20,8 +20,8 @@ import cats.MonadThrow
 import io.chrisdavenport.log4cats.Logger
 import org.http4s.Header
 import org.scalasteward.core.application.Config
-import org.scalasteward.core.application.SupportedVCS.{Bitbucket, BitbucketServer, GitHub, GitLab}
 import org.scalasteward.core.util.HttpJsonClient
+import org.scalasteward.core.vcs.VCSType.{Bitbucket, BitbucketServer, GitHub, GitLab}
 import org.scalasteward.core.vcs.bitbucket.BitbucketApiAlg
 import org.scalasteward.core.vcs.bitbucketserver.BitbucketServerApiAlg
 import org.scalasteward.core.vcs.data.AuthenticatedUser
diff --git a/modules/core/src/main/scala/org/scalasteward/core/application/SupportedVCS.scala b/modules/core/src/main/scala/org/scalasteward/core/vcs/VCSType.scala
similarity index 72%
rename from modules/core/src/main/scala/org/scalasteward/core/application/SupportedVCS.scala
rename to modules/core/src/main/scala/org/scalasteward/core/vcs/VCSType.scala
index 2711beff..22e4f7d6 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/application/SupportedVCS.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/vcs/VCSType.scala
@@ -14,13 +14,13 @@
  * limitations under the License.
  */
 
-package org.scalasteward.core.application
+package org.scalasteward.core.vcs
 
 import cats.Eq
 import cats.syntax.all._
-import org.scalasteward.core.application.SupportedVCS._
+import org.scalasteward.core.vcs.VCSType._
 
-sealed trait SupportedVCS {
+sealed trait VCSType {
   val asString: String = this match {
     case Bitbucket       => "bitbucket"
     case BitbucketServer => "bitbucket-server"
@@ -29,21 +29,21 @@ sealed trait SupportedVCS {
   }
 }
 
-object SupportedVCS {
-  case object Bitbucket extends SupportedVCS
-  case object BitbucketServer extends SupportedVCS
-  case object GitHub extends SupportedVCS
-  case object GitLab extends SupportedVCS
+object VCSType {
+  case object Bitbucket extends VCSType
+  case object BitbucketServer extends VCSType
+  case object GitHub extends VCSType
+  case object GitLab extends VCSType
 
   val all = List(Bitbucket, BitbucketServer, GitHub, GitLab)
 
-  def parse(s: String): Either[String, SupportedVCS] =
+  def parse(s: String): Either[String, VCSType] =
     all.find(_.asString === s) match {
       case Some(value) => Right(value)
       case None =>
         Left(s"Unexpected string '$s'. Expected one of: ${all.map(_.asString).mkString(", ")}.")
     }
 
-  implicit val supportedVCSEq: Eq[SupportedVCS] =
+  implicit val vcsTypeEq: Eq[VCSType] =
     Eq.fromUniversalEquals
 }
diff --git a/modules/core/src/main/scala/org/scalasteward/core/vcs/package.scala b/modules/core/src/main/scala/org/scalasteward/core/vcs/package.scala
index e21499bd..1e283cde 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/vcs/package.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/vcs/package.scala
@@ -18,10 +18,9 @@ package org.scalasteward.core
 
 import cats.syntax.all._
 import org.http4s.Uri
-import org.scalasteward.core.application.SupportedVCS
-import org.scalasteward.core.application.SupportedVCS.{Bitbucket, BitbucketServer, GitHub, GitLab}
 import org.scalasteward.core.data.ReleaseRelatedUrl.VersionDiff
 import org.scalasteward.core.data.{ReleaseRelatedUrl, Update}
+import org.scalasteward.core.vcs.VCSType.{Bitbucket, BitbucketServer, GitHub, GitLab}
 import org.scalasteward.core.vcs.data.{PullRequestNumber, Repo}
 
 package object vcs {
@@ -36,7 +35,7 @@ package object vcs {
   /** Determines the `head` (GitHub) / `source_branch` (GitLab, Bitbucket) parameter for searching
     * for already existing pull requests.
     */
-  def listingBranch(vcsType: SupportedVCS, fork: Repo, update: Update): String =
+  def listingBranch(vcsType: VCSType, fork: Repo, update: Update): String =
     vcsType match {
       case GitHub =>
         s"${fork.show}:${git.branchFor(update).name}"
@@ -48,7 +47,7 @@ package object vcs {
   /** Determines the `head` (GitHub) / `source_branch` (GitLab, Bitbucket) parameter for creating
     * a new pull requests.
     */
-  def createBranch(vcsType: SupportedVCS, fork: Repo, update: Update): String =
+  def createBranch(vcsType: VCSType, fork: Repo, update: Update): String =
     vcsType match {
       case GitHub =>
         s"${fork.owner}:${git.branchFor(update).name}"
@@ -81,10 +80,10 @@ package object vcs {
   }
 
   private[this] def extractRepoVCSType(
-      vcsType: SupportedVCS,
+      vcsType: VCSType,
       vcsUri: Uri,
       repoUrl: Uri
-  ): Option[SupportedVCS] = {
+  ): Option[VCSType] = {
     val host = repoUrl.host.map(_.value)
     if (vcsUri.host.map(_.value).contains(host.getOrElse("")))
       Some(vcsType)
@@ -97,7 +96,7 @@ package object vcs {
   }
 
   def possibleCompareUrls(
-      vcsType: SupportedVCS,
+      vcsType: VCSType,
       vcsUri: Uri,
       repoUrl: Uri,
       update: Update
@@ -120,7 +119,7 @@ package object vcs {
   }
 
   def possibleReleaseRelatedUrls(
-      vcsType: SupportedVCS,
+      vcsType: VCSType,
       vcsUri: Uri,
       repoUrl: Uri,
       update: Update
@@ -137,8 +136,8 @@ package object vcs {
 
     def files(fileNames: List[String]): List[Uri] = {
       val maybeSegments = repoVCSType.map {
-        case SupportedVCS.GitHub | SupportedVCS.GitLab             => List("blob", "master")
-        case SupportedVCS.Bitbucket | SupportedVCS.BitbucketServer => List("master")
+        case GitHub | GitLab             => List("blob", "master")
+        case Bitbucket | BitbucketServer => List("master")
       }
 
       maybeSegments.toList.flatMap { segments =>
@@ -151,12 +150,8 @@ package object vcs {
     val customReleaseNotes =
       files(possibleReleaseNotesFilenames).map(ReleaseRelatedUrl.CustomReleaseNotes)
 
-    github ++ customReleaseNotes ++ customChangelog ++ possibleCompareUrls(
-      vcsType,
-      vcsUri,
-      repoUrl,
-      update
-    )
+    github ++ customReleaseNotes ++ customChangelog ++
+      possibleCompareUrls(vcsType, vcsUri, repoUrl, update)
   }
 
   private def possibleFilenames(baseNames: List[String]): List[String] = {


Test patch:
diff --git a/modules/core/src/test/scala/org/scalasteward/core/application/CliTest.scala b/modules/core/src/test/scala/org/scalasteward/core/application/CliTest.scala
index c091e686..fda255ed 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/application/CliTest.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/application/CliTest.scala
@@ -5,6 +5,7 @@ import munit.FunSuite
 import org.http4s.syntax.literals._
 import org.scalasteward.core.application.Cli.EnvVar
 import org.scalasteward.core.application.Cli.ParseResult._
+import org.scalasteward.core.vcs.VCSType
 import scala.concurrent.duration._
 
 class CliTest extends FunSuite {
@@ -36,7 +37,7 @@ class CliTest extends FunSuite {
         reposFile = File("b"),
         defaultRepoConf = Some(File("c")),
         gitAuthorEmail = "d",
-        vcsType = SupportedVCS.GitLab,
+        vcsType = VCSType.GitLab,
         vcsApiHost = uri"http://example.com",
         vcsLogin = "e",
         gitAskPass = File("f"),
@@ -122,7 +123,7 @@ class CliTest extends FunSuite {
     assert(clue(Cli.fileArgParser(Some(File("/tmp")), "/opt")).isLeft)
   }
 
-  test("supportedVCSArgParser: unknown value") {
-    assert(clue(Cli.supportedVCSArgParser(None, "sourceforge")).isLeft)
+  test("vcsTypeArgParser: unknown value") {
+    assert(clue(Cli.vcsTypeArgParser(None, "sourceforge")).isLeft)
   }
 }
diff --git a/modules/core/src/test/scala/org/scalasteward/core/mock/MockContext.scala b/modules/core/src/test/scala/org/scalasteward/core/mock/MockContext.scala
index 4f6bb98e..a0661bd2 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/mock/MockContext.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/mock/MockContext.scala
@@ -8,9 +8,10 @@ import org.http4s.client.Client
 import org.http4s.{HttpApp, Uri}
 import org.scalasteward.core.TestInstances.ioContextShift
 import org.scalasteward.core.application.Cli.EnvVar
-import org.scalasteward.core.application.{Cli, Config, Context, SupportedVCS}
+import org.scalasteward.core.application.{Cli, Config, Context}
 import org.scalasteward.core.io._
 import org.scalasteward.core.scalafix.MigrationsLoaderTest
+import org.scalasteward.core.vcs.VCSType
 import org.scalasteward.core.vcs.data.AuthenticatedUser
 import scala.concurrent.duration._
 
@@ -21,7 +22,7 @@ object MockContext {
     defaultRepoConf = Some(File.temp / "default.scala-steward.conf"),
     gitAuthorName = "Bot Doe",
     gitAuthorEmail = "bot@example.org",
-    vcsType = SupportedVCS.GitHub,
+    vcsType = VCSType.GitHub,
     vcsApiHost = Uri(),
     vcsLogin = "bot-doe",
     gitAskPass = File.temp / "askpass.sh",
diff --git a/modules/core/src/test/scala/org/scalasteward/core/vcs/VCSExtraAlgTest.scala b/modules/core/src/test/scala/org/scalasteward/core/vcs/VCSExtraAlgTest.scala
index 9a28cc8a..d0ede26a 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/vcs/VCSExtraAlgTest.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/vcs/VCSExtraAlgTest.scala
@@ -8,7 +8,6 @@ import org.http4s.dsl.io._
 import org.http4s.implicits._
 import org.scalasteward.core.TestInstances.ioLogger
 import org.scalasteward.core.TestSyntax._
-import org.scalasteward.core.application.SupportedVCS
 import org.scalasteward.core.data.{ReleaseRelatedUrl, Update}
 import org.scalasteward.core.mock.MockContext
 import org.scalasteward.core.util.{Nel, UrlChecker}
@@ -58,7 +57,7 @@ class VCSExtraAlgTest extends FunSuite {
 
   test("getBranchCompareUrl: github on prem") {
     val config = MockContext.config.copy(
-      vcsType = SupportedVCS.GitHub,
+      vcsType = VCSType.GitHub,
       vcsApiHost = uri"https://github.on-prem.com/"
     )
     val githubOnPremVcsExtraAlg = VCSExtraAlg.create[IO](config)
diff --git a/modules/core/src/test/scala/org/scalasteward/core/vcs/VCSPackageTest.scala b/modules/core/src/test/scala/org/scalasteward/core/vcs/VCSPackageTest.scala
index 99ccdb02..0498ed2a 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/vcs/VCSPackageTest.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/vcs/VCSPackageTest.scala
@@ -3,10 +3,9 @@ package org.scalasteward.core.vcs
 import munit.FunSuite
 import org.http4s.syntax.literals._
 import org.scalasteward.core.TestSyntax._
-import org.scalasteward.core.application.SupportedVCS
-import org.scalasteward.core.application.SupportedVCS.{GitHub, GitLab}
 import org.scalasteward.core.data.Update
 import org.scalasteward.core.util.Nel
+import org.scalasteward.core.vcs.VCSType.{GitHub, GitLab}
 import org.scalasteward.core.vcs.data.{PullRequestNumber, Repo}
 
 class VCSPackageTest extends FunSuite {
@@ -52,7 +51,7 @@ class VCSPackageTest extends FunSuite {
 
     assertEquals(
       possibleCompareUrls(
-        SupportedVCS.GitHub,
+        GitHub,
         onPremVCSUri,
         uri"https://github.com/foo/bar",
         update
@@ -67,7 +66,7 @@ class VCSPackageTest extends FunSuite {
     // should canonicalize (drop last slash)
     assertEquals(
       possibleCompareUrls(
-        SupportedVCS.GitHub,
+        GitHub,
         onPremVCSUri,
         uri"https://github.com/foo/bar/",
         update
@@ -81,7 +80,7 @@ class VCSPackageTest extends FunSuite {
 
     assertEquals(
       possibleCompareUrls(
-        SupportedVCS.GitHub,
+        GitHub,
         onPremVCSUri,
         uri"https://gitlab.com/foo/bar",
         update
@@ -95,7 +94,7 @@ class VCSPackageTest extends FunSuite {
 
     assertEquals(
       possibleCompareUrls(
-        SupportedVCS.GitHub,
+        GitHub,
         onPremVCSUri,
         uri"https://bitbucket.org/foo/bar",
         update
@@ -109,7 +108,7 @@ class VCSPackageTest extends FunSuite {
 
     assertEquals(
       possibleCompareUrls(
-        SupportedVCS.GitHub,
+        GitHub,
         onPremVCSUri,
         uri"https://scalacenter.github.io/scalafix/",
         update
@@ -119,7 +118,7 @@ class VCSPackageTest extends FunSuite {
 
     assertEquals(
       possibleCompareUrls(
-        SupportedVCS.GitHub,
+        GitHub,
         onPremVCSUri,
         onPremVCSUri.addPath("/foo/bar"),
         update
@@ -134,7 +133,7 @@ class VCSPackageTest extends FunSuite {
 
   test("possibleChangelogUrls: github.com") {
     val obtained = possibleReleaseRelatedUrls(
-      SupportedVCS.GitHub,
+      GitHub,
       uri"https://github.com",
       uri"https://github.com/foo/bar",
       update
@@ -176,7 +175,7 @@ class VCSPackageTest extends FunSuite {
 
   test("possibleChangelogUrls: gitlab.com") {
     val obtained = possibleReleaseRelatedUrls(
-      SupportedVCS.GitHub,
+      GitHub,
       uri"https://github.com",
       uri"https://gitlab.com/foo/bar",
       update
@@ -194,7 +193,7 @@ class VCSPackageTest extends FunSuite {
 
   test("possibleChangelogUrls: on-prem gitlab") {
     val obtained = possibleReleaseRelatedUrls(
-      SupportedVCS.GitLab,
+      GitLab,
       uri"https://gitlab.on-prem.net",
       uri"https://gitlab.on-prem.net/foo/bar",
       update
@@ -213,7 +212,7 @@ class VCSPackageTest extends FunSuite {
 
   test("possibleChangelogUrls: bitbucket.org") {
     val obtained = possibleReleaseRelatedUrls(
-      SupportedVCS.GitHub,
+      GitHub,
       uri"https://github.com",
       uri"https://bitbucket.org/foo/bar",
       update
@@ -231,7 +230,7 @@ class VCSPackageTest extends FunSuite {
 
   test("possibleChangelogUrls: homepage") {
     val obtained = possibleReleaseRelatedUrls(
-      SupportedVCS.GitHub,
+      GitHub,
       uri"https://github.com",
       uri"https://scalacenter.github.io/scalafix/",
       update