From 30ce1c1ec1c7f9cdf0f2c5f6fdd278860ccce5d1 Mon Sep 17 00:00:00 2001 From: "aristov.konstantin@sgaz.local" Date: Wed, 3 Apr 2024 16:05:50 +0500 Subject: [PATCH 1/4] Using a comparison that supports semver --- build.sbt | 4 ++-- src/main/scala/com/github/sbt/git/GitPlugin.scala | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index bf53840..964c345 100644 --- a/build.sbt +++ b/build.sbt @@ -15,8 +15,8 @@ git.baseVersion := "1.0" libraryDependencies ++= Seq( "org.eclipse.jgit" % "org.eclipse.jgit" % "5.13.3.202401111512-r", - "com.michaelpollmeier" % "versionsort" % "1.0.11", - "org.scalameta" %% "munit" % "1.0.1" % Test + "com.github.zafarkhaja" % "java-semver" % "0.10.2", + "org.scalameta" %% "munit" % "1.0.1" % Test, ) scriptedLaunchOpts += s"-Dproject.version=${version.value}" diff --git a/src/main/scala/com/github/sbt/git/GitPlugin.scala b/src/main/scala/com/github/sbt/git/GitPlugin.scala index 8e9c8a5..612e44a 100644 --- a/src/main/scala/com/github/sbt/git/GitPlugin.scala +++ b/src/main/scala/com/github/sbt/git/GitPlugin.scala @@ -1,7 +1,9 @@ package com.github.sbt.git -import sbt._ -import Keys._ +import sbt.* +import Keys.* +import com.github.zafarkhaja.semver.Version + import sys.process.Process /** This plugin has all the basic 'git' functionality for other plugins. */ @@ -299,7 +301,12 @@ object SbtGit { } yield version // NOTE - Selecting the last tag or the first tag should be an option. - val highestVersion = versions.sortWith { versionsort.VersionHelper.compare(_, _) > 0 }.headOption + val highestVersion = + versions + .map(Version.parse) + .sortWith(_.compareTo(_) > 0) + .headOption + highestVersion.map(_ + suffix) } From 3f8a4f116573ff02a06aedba8c7c721a79d52ada Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Sat, 7 Sep 2024 16:34:51 +0200 Subject: [PATCH 2/4] upgrade to sbt 1.10.1 everywhere Steward missed some places when we went to 1.10.0, maybe having them all in sync now means it will get them all next time? --- build.sbt | 2 +- project/build.properties | 2 +- test-project/project/build.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 964c345..c31b7f2 100644 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,7 @@ startYear := Some(2011) homepage := scmInfo.value map (_.browseUrl) scmInfo := Some(ScmInfo(url("https://github.com/sbt/sbt-git"), "scm:git:git@github.com:sbt/sbt-git.git")) -crossSbtVersions := List("1.3.13") +crossSbtVersions := List("1.10.1") enablePlugins(GitVersioning, SbtPlugin) git.baseVersion := "1.0" diff --git a/project/build.properties b/project/build.properties index 081fdbb..ee4c672 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.10.0 +sbt.version=1.10.1 diff --git a/test-project/project/build.properties b/test-project/project/build.properties index 8b697bb..ee4c672 100644 --- a/test-project/project/build.properties +++ b/test-project/project/build.properties @@ -1 +1 @@ -sbt.version=1.1.0 +sbt.version=1.10.1 From db0e5de35ed709d094dc5c370f21daa3d2ffc6df Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Sat, 7 Sep 2024 16:36:18 +0200 Subject: [PATCH 3/4] silence a build warning --- src/main/scala/com/github/sbt/git/GitPlugin.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/sbt/git/GitPlugin.scala b/src/main/scala/com/github/sbt/git/GitPlugin.scala index 612e44a..9a81ca8 100644 --- a/src/main/scala/com/github/sbt/git/GitPlugin.scala +++ b/src/main/scala/com/github/sbt/git/GitPlugin.scala @@ -164,7 +164,7 @@ object SbtGit { def useJGit: Setting[_] = ThisBuild / gitRunner := JGitRunner /** Setting to use console git for readable ops, to allow working with git worktrees */ - def useReadableConsoleGit: Setting[_] = useConsoleForROGit in ThisBuild := true + def useReadableConsoleGit: Setting[_] = ThisBuild / useConsoleForROGit := true /** Adapts the project prompt to show the current project name *and* the current git branch. */ def showCurrentGitBranch: Setting[_] = From 612b212aaa735fd7852b2066b740e9c59bbd83d6 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Sat, 7 Sep 2024 16:46:39 +0200 Subject: [PATCH 4/4] fix a deprecation warning --- src/main/scala/com/github/sbt/git/ConsoleGitRunner.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/sbt/git/ConsoleGitRunner.scala b/src/main/scala/com/github/sbt/git/ConsoleGitRunner.scala index a471e82..0d3f229 100644 --- a/src/main/scala/com/github/sbt/git/ConsoleGitRunner.scala +++ b/src/main/scala/com/github/sbt/git/ConsoleGitRunner.scala @@ -16,9 +16,11 @@ object ConsoleGitRunner extends GitRunner { private lazy val cmd = if(isWindowsShell) Seq("cmd", "/c", "git") else Seq("git") // in order to enable colors we trick git into thinking we're a pager, because it already knows we're not a tty - val colorSupport: Seq[(String, String)] = - if(ConsoleLogger.formatEnabled) Seq("GIT_PAGER_IN_USE" -> "1") + val colorSupport: Seq[(String, String)] = { + import sbt.internal.util.Terminal.console + if(console.isAnsiSupported && console.isColorEnabled) Seq("GIT_PAGER_IN_USE" -> "1") else Seq.empty + } override def apply(args: String*)(cwd: File, log: Logger = ConsoleLogger()): String = { val gitLogger = new GitLogger(log)