From 9cf52dccc6537cd6caffc8644843f22ee7554054 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Sat, 1 Apr 2017 21:42:44 +0100 Subject: [PATCH] Introduce GitRef.isTag & GitCommitSuffix.isEmpty --- src/main/scala/sbtdynver/DynVerPlugin.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/scala/sbtdynver/DynVerPlugin.scala b/src/main/scala/sbtdynver/DynVerPlugin.scala index 98c082a..905bb09 100644 --- a/src/main/scala/sbtdynver/DynVerPlugin.scala +++ b/src/main/scala/sbtdynver/DynVerPlugin.scala @@ -39,6 +39,7 @@ final case class GitDirtySuffix(value: String) object GitRef extends (String => GitRef) { final implicit class GitRefOps(val x: GitRef) extends AnyVal { import x._ + def isTag: Boolean = value startsWith "v" def dropV: GitRef = GitRef(value.replaceAll("^v", "")) def mkString(prefix: String, suffix: String): String = if (value.isEmpty) "" else prefix + value + suffix } @@ -46,8 +47,9 @@ object GitRef extends (String => GitRef) { object GitCommitSuffix extends ((Int, String) => GitCommitSuffix) { final implicit class GitCommitSuffixOps(val x: GitCommitSuffix) extends AnyVal { import x._ + def isEmpty: Boolean = distance <= 0 || sha.isEmpty def mkString(prefix: String, infix: String, suffix: String): String = - if (distance <= 0 || sha.isEmpty) "" else prefix + distance + infix + sha + suffix + if (isEmpty) "" else prefix + distance + infix + sha + suffix } } @@ -63,7 +65,7 @@ final case class GitDescribeOutput(ref: GitRef, commitSuffix: GitCommitSuffix, d def isSnapshot(): Boolean = isDirty() || hasNoTags() def isDirty(): Boolean = dirtySuffix.value.nonEmpty - def hasNoTags(): Boolean = !(ref.value startsWith "v") + def hasNoTags(): Boolean = !ref.isTag } object GitDescribeOutput extends ((GitRef, GitCommitSuffix, GitDirtySuffix) => GitDescribeOutput) {