Skip to content

Commit

Permalink
Append +0 to first dirty commit after tag
Browse files Browse the repository at this point in the history
Fixes sbt#52
  • Loading branch information
leonardehrenfried committed Feb 25, 2018
1 parent 7c54d8c commit 437a704
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/main/scala/sbtdynver/DynVerPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ object GitDirtySuffix extends (String => GitDirtySuffix) {
}

final case class GitDescribeOutput(ref: GitRef, commitSuffix: GitCommitSuffix, dirtySuffix: GitDirtySuffix) {
def version: String = ref.dropV.value + commitSuffix.mkString("+", "-", "") + dirtySuffix.value
def version: String = {
if(isDirtyAfterTag) s"${ref.dropV.value}+0-${dirtySuffix.dropPlus.value}"
else ref.dropV.value + commitSuffix.mkString("+", "-", "") + dirtySuffix.value
}

def isDirtyAfterTag = commitSuffix.distance == 0 && ref.isTag && isDirty()
def isSnapshot(): Boolean = isDirty() || hasNoTags() || commitSuffix.distance > 0
def isVersionStable(): Boolean = !isDirty()

Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/sbtdynver/DynVerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object VersionSpec extends Properties("VersionSpec") {
property("on commit, w/o local changes") = onCommit().version() ?= "1234abcd"
property("on commit with local changes") = onCommitDirty().version() ?= "1234abcd+20160917-0000"
property("on tag v1.0.0, w/o local changes") = onTag().version() ?= "1.0.0"
property("on tag v1.0.0 with local changes") = onTagDirty().version() ?= "1.0.0+20160917-0000"
property("on tag v1.0.0 with local changes") = onTagDirty().version() ?= "1.0.0+0-20160917-0000"
property("on tag v1.0.0 and 1 commit, w/o local changes") = onTagAndCommit().version() ?= "1.0.0+1-1234abcd"
property("on tag v1.0.0 and 1 commit with local changes") = onTagAndCommitDirty().version() ?= "1.0.0+1-1234abcd+20160917-0000"
}
Expand Down

0 comments on commit 437a704

Please sign in to comment.