From 078860e9a0c69f73cbc75bdd218409a020978a87 Mon Sep 17 00:00:00 2001 From: Mike Limansky Date: Wed, 18 Dec 2024 22:25:51 +0300 Subject: [PATCH 1/3] Update sbt 2 up to 2.0.0-M3 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 41acbe3..707351f 100644 --- a/build.sbt +++ b/build.sbt @@ -25,7 +25,7 @@ libraryDependencies ++= Seq( (pluginCrossBuild / sbtVersion) := { scalaBinaryVersion.value match { case "2.12" => "1.5.8" - case _ => "2.0.0-M2" + case _ => "2.0.0-M3" } } From 0a4ca0285a4f9fc63a160ed9d3fa45de66f10acd Mon Sep 17 00:00:00 2001 From: Mike Limansky Date: Wed, 18 Dec 2024 23:12:59 +0300 Subject: [PATCH 2/3] Align Scala 3 version with sbt-2.0.0-M3 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 707351f..f14e201 100644 --- a/build.sbt +++ b/build.sbt @@ -9,7 +9,7 @@ homepage := scmInfo.value map (_.browseUrl) scmInfo := Some(ScmInfo(url("https://github.com/sbt/sbt-git"), "scm:git:git@github.com:sbt/sbt-git.git")) lazy val scala212 = "2.12.20" -lazy val scala3 = "3.3.4" +lazy val scala3 = "3.6.2" crossScalaVersions := Seq(scala212, scala3) From e867815c32604956a545b1712e02b46f47004b8c Mon Sep 17 00:00:00 2001 From: Mike Limansky Date: Wed, 18 Dec 2024 23:29:19 +0300 Subject: [PATCH 3/3] Fix Scala 3 compiler warnings --- src/main/scala/com/github/sbt/git/GitPlugin.scala | 12 ++++++------ src/main/scala/com/github/sbt/git/JGit.scala | 2 +- src/main/scala/com/github/sbt/git/ReadableGit.scala | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/scala/com/github/sbt/git/GitPlugin.scala b/src/main/scala/com/github/sbt/git/GitPlugin.scala index 6612906..fe763d7 100644 --- a/src/main/scala/com/github/sbt/git/GitPlugin.scala +++ b/src/main/scala/com/github/sbt/git/GitPlugin.scala @@ -100,9 +100,9 @@ object SbtGit { val prompt: State => String = { state => val extracted = Project.extract(state) - val reader = extracted get GitKeys.gitReader - val dir = extracted get baseDirectory - val name = extracted get Keys.name + val reader = extracted `get` GitKeys.gitReader + val dir = extracted `get` baseDirectory + val name = extracted `get` Keys.name if (isGitRepo(dir)) { val branch = reader.withGit(_.branch) name + "(" + branch + ")> " @@ -284,7 +284,7 @@ object SbtGit { val formattedDateVersion = ThisBuild / GitKeys.formattedDateVersion val defaultTagByVersionStrategy: String => Option[String] = { tag => - if (tag matches "v[0-9].*") Some(tag drop 1) + if (tag `matches` "v[0-9].*") Some(tag drop 1) else None } @@ -294,8 +294,8 @@ object SbtGit { def defaultFormatDateVersion(baseVersion: Option[String], date: java.util.Date): String = { val df = new java.text.SimpleDateFormat("yyyyMMdd'T'HHmmss") - df setTimeZone java.util.TimeZone.getTimeZone("GMT") - baseVersion.map(_ + "-").getOrElse("") + (df format (new java.util.Date)) + df.setTimeZone(java.util.TimeZone.getTimeZone("GMT")) + baseVersion.map(_ + "-").getOrElse("") + (df.format(new java.util.Date)) } def flaggedOptional(flag: Boolean, value: Option[String]): Option[String] = diff --git a/src/main/scala/com/github/sbt/git/JGit.scala b/src/main/scala/com/github/sbt/git/JGit.scala index ebbd631..af6761c 100644 --- a/src/main/scala/com/github/sbt/git/JGit.scala +++ b/src/main/scala/com/github/sbt/git/JGit.scala @@ -66,7 +66,7 @@ final class JGit(val repo: Repository) extends GitReadonlyInterface { taghash = tagHash(unpeeledTag) if taghash == hash ref = unpeeledTag.getName - if ref startsWith "refs/tags/" + if ref `startsWith` "refs/tags/" } yield ref drop 10 } diff --git a/src/main/scala/com/github/sbt/git/ReadableGit.scala b/src/main/scala/com/github/sbt/git/ReadableGit.scala index 0f20597..98d36a9 100644 --- a/src/main/scala/com/github/sbt/git/ReadableGit.scala +++ b/src/main/scala/com/github/sbt/git/ReadableGit.scala @@ -36,7 +36,7 @@ trait GitReadonlyInterface { final class DefaultReadableGit(base: sbt.File, gitOverride: Option[GitReadonlyInterface]) extends ReadableGit { // TODO - Should we cache git, or just create on each request? // For now, let's cache. - private[this] val git = gitOverride getOrElse JGit(base) + private val git = gitOverride getOrElse JGit(base) /** Use the git read-only interface. */ def withGit[A](f: GitReadonlyInterface => A): A = // JGit has concurrency issues so we synchronize access to it.