From cd3e3cd748998afa3f55c4c330907dd1891e91e0 Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Wed, 18 Oct 2023 23:30:05 -0700 Subject: [PATCH] Adding a describedVersion(...) for ConsoleGitReadableOnly --- .../scala/com/github/sbt/git/ConsoleGitReadableOnly.scala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/scala/com/github/sbt/git/ConsoleGitReadableOnly.scala b/src/main/scala/com/github/sbt/git/ConsoleGitReadableOnly.scala index 0ff326f..0df62b0 100644 --- a/src/main/scala/com/github/sbt/git/ConsoleGitReadableOnly.scala +++ b/src/main/scala/com/github/sbt/git/ConsoleGitReadableOnly.scala @@ -15,6 +15,11 @@ class ConsoleGitReadableOnly(git: GitRunner, cwd: File, log: Logger) extends Git def describedVersion: Option[String] = Try(git("describe", "--tags")(cwd, log).split("\\s+").headOption).toOption.flatten + override def describedVersion(patterns: Seq[String]): Option[String] = + patterns.headOption.fold(describedVersion)(pat => + Try(git("describe", "--tags", "--match", pat)(cwd, log).split("\\s+").headOption).toOption.flatten + ) + def hasUncommittedChanges: Boolean = Try(!git("status", "-s")(cwd, log).trim.isEmpty).getOrElse(true) def branches: Seq[String] = Try(git("branch", "--list")(cwd, log).split("\\s+").toSeq).getOrElse(Seq())