From d581ef24a1f4dec7bd8291587134e5b7ada4af46 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 18 Jan 2022 10:28:28 +0000 Subject: [PATCH 1/2] Make previousReleases strictly previous --- .../src/main/scala/org/typelevel/sbt/kernel/GitHelper.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/src/main/scala/org/typelevel/sbt/kernel/GitHelper.scala b/kernel/src/main/scala/org/typelevel/sbt/kernel/GitHelper.scala index d4b50a70..245cc6fc 100644 --- a/kernel/src/main/scala/org/typelevel/sbt/kernel/GitHelper.scala +++ b/kernel/src/main/scala/org/typelevel/sbt/kernel/GitHelper.scala @@ -23,13 +23,15 @@ import scala.sys.process._ object GitHelper { /** + * Returns a list of strictly previous releases (i.e. ignores tags on HEAD). * @param fromHead * if `true`, only tags reachable from HEAD's history. If `false`, all tags in the repo. */ def previousReleases(fromHead: Boolean = false): List[V] = { Try { val merged = if (fromHead) " --merged" else "" - s"git tag --list$merged".!!.split("\n").toList.map(_.trim).collect { + // --no-contains omits tags on HEAD + s"git tag --no-contains$merged".!!.split("\n").toList.map(_.trim).collect { case V.Tag(version) => version } }.getOrElse(List.empty).sorted.reverse From 31b32bb1b69afbb46eccaaf2bf0e808a30ddb764 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 18 Jan 2022 10:36:25 +0000 Subject: [PATCH 2/2] Fix git command --- .../src/main/scala/org/typelevel/sbt/kernel/GitHelper.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/src/main/scala/org/typelevel/sbt/kernel/GitHelper.scala b/kernel/src/main/scala/org/typelevel/sbt/kernel/GitHelper.scala index 245cc6fc..f48c421b 100644 --- a/kernel/src/main/scala/org/typelevel/sbt/kernel/GitHelper.scala +++ b/kernel/src/main/scala/org/typelevel/sbt/kernel/GitHelper.scala @@ -29,9 +29,9 @@ object GitHelper { */ def previousReleases(fromHead: Boolean = false): List[V] = { Try { - val merged = if (fromHead) " --merged" else "" + val merged = if (fromHead) " --merged HEAD" else "" // --no-contains omits tags on HEAD - s"git tag --no-contains$merged".!!.split("\n").toList.map(_.trim).collect { + s"git tag --no-contains HEAD$merged".!!.split("\n").toList.map(_.trim).collect { case V.Tag(version) => version } }.getOrElse(List.empty).sorted.reverse