-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document & test simple post-process solution
Fixes #5 (alternative fix)
- Loading branch information
Showing
4 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
version in ThisBuild ~= (_.replace('+', '-')) | ||
dynver in ThisBuild ~= (_.replace('+', '-')) | ||
|
||
def tstamp = Def.setting(sbtdynver.DynVer timestamp dynverCurrentDate.value) | ||
def headSha = Def.task("git rev-parse --short=8 HEAD".!!(streams.value.log).trim) | ||
|
||
def check(a: String, e: String) = assert(a == e, s"Version mismatch: Expected $e, Incoming $a") | ||
|
||
TaskKey[Unit]("checkNotAGitRepo") := check(version.value, s"HEAD-${tstamp.value}") | ||
TaskKey[Unit]("checkNoCommits") := check(version.value, s"HEAD-${tstamp.value}") | ||
TaskKey[Unit]("checkOnCommit") := check(version.value, s"${headSha.value}") | ||
TaskKey[Unit]("checkOnCommitDirty") := check(version.value, s"${headSha.value}-${tstamp.value}") | ||
TaskKey[Unit]("checkOnTag") := check(version.value, s"1.0.0") | ||
TaskKey[Unit]("checkOnTagDirty") := check(version.value, s"1.0.0-${tstamp.value}") | ||
TaskKey[Unit]("checkOnTagAndCommit") := check(version.value, s"1.0.0-1-${headSha.value}") | ||
TaskKey[Unit]("checkOnTagAndCommitDirty") := check(version.value, s"1.0.0-1-${headSha.value}-${tstamp.value}") | ||
|
||
TaskKey[Unit]("gitInitSetup") := { | ||
"git init".!!(streams.value.log) | ||
"git config user.email [email protected]".!!(streams.value.log) | ||
"git config user.name dynver".!!(streams.value.log) | ||
} | ||
|
||
TaskKey[Unit]("gitAdd") := "git add .".!!(streams.value.log) | ||
TaskKey[Unit]("gitCommit") := "git commit -am1".!!(streams.value.log) | ||
TaskKey[Unit]("gitTag") := "git tag -a v1.0.0 -m1.0.0".!!(streams.value.log) | ||
|
||
TaskKey[Unit]("dirty") := { | ||
import java.nio.file._, StandardOpenOption._ | ||
import scala.collection.JavaConverters._ | ||
Files.write(baseDirectory.value.toPath.resolve("f.txt"), Seq("1").asJava, CREATE, APPEND) | ||
} |
5 changes: 5 additions & 0 deletions
5
src/sbt-test/dynver/custom-version-string-0/project/plugins.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
sys.props.get("plugin.version") match { | ||
case Some(x) => addSbtPlugin("com.dwijnand" % "sbt-dynver" % x) | ||
case _ => sys.error("""|The system property 'plugin.version' is not defined. | ||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
> checkNotAGitRepo | ||
|
||
> gitInitSetup | ||
> reload | ||
> checkNoCommits | ||
|
||
> dirty | ||
> gitAdd | ||
> gitCommit | ||
> reload | ||
> checkOnCommit | ||
|
||
> dirty | ||
> reload | ||
> checkOnCommitDirty | ||
|
||
> gitCommit | ||
> gitTag | ||
> reload | ||
> checkOnTag | ||
|
||
> dirty | ||
> reload | ||
> checkOnTagDirty | ||
|
||
> gitCommit | ||
> reload | ||
> checkOnTagAndCommit | ||
|
||
> dirty | ||
> reload | ||
> checkOnTagAndCommitDirty |