Commit c09a075b authored by 35V LG84's avatar 35V LG84

Commit id with `--version`

Report git commit id and modified state with `--version`.
Signed-off-by: 35V LG84's avatar35V LG84 <35vlg84-x4e6b92@e257.fi>
parent 45d9532a
......@@ -16,6 +16,7 @@ New features and changes in this release:
* Update better-files to 3.8.0
** 3.8.0 is not binary compatible with
link:https://github.com/pathikrit/better-files/issues/301[better-files 3.7.0]
* CLI: Raport Git commit id and working copy state with version info for `--help` and `--version` commands
* ...
** ...
......@@ -34,6 +35,7 @@ Updated deps and tools:
** scallop: 3.3.0
* Build
** sbt-coveralls: drop
** sbt-git: 1.0.0 (new)
** sbt-scoverage: 1.6.0-RC1
** sbt-wartremover: 2.4.2
* Tests
......
......@@ -131,6 +131,8 @@ lazy val core = (project in file("core")).
libraryDependencies ++= circe_deps_test,
)
val gitCommitId = SettingKey[String]("gitCommit")
val gitLocalChanges = SettingKey[Boolean]("gitUncommittedChanges")
lazy val cli = (project in file("cli")).
enablePlugins(BuildInfoPlugin).
......@@ -152,7 +154,9 @@ lazy val cli = (project in file("cli")).
},
assembly / test := {},
assemblyJarName in assembly := "tackler-cli" + "-" + version.value + ".jar",
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
gitCommitId := git.gitHeadCommit.value.getOrElse("Not available"),
gitLocalChanges := git.gitUncommittedChanges.value,
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion, gitCommitId, gitLocalChanges),
// Do not enable BuildInfoOption.BuildTime, it breaks coverage analysis of test + it:test
// targets because it causes recompilation, which in turn causes scoverage to clear instrumentation cache
// https://github.com/scoverage/sbt-scoverage/issues/277
......
......@@ -37,6 +37,14 @@ object TacklerCli {
val SUCCESS: Int = 0
val FAILURE: Int = 127
def yesno(b: Boolean): String = { if (b) "Yes" else "No" }
def version() : String = {
s"""Version: ${BuildInfo.version}
|Commit: ${BuildInfo.gitCommit}
|Modified: ${yesno(BuildInfo.gitUncommittedChanges)}
""".stripMargin
}
/**
* Get CFG path either by optional arg, or if arg is not provided
......@@ -234,7 +242,7 @@ object TacklerCli {
case org.rogach.scallop.exceptions.Version =>
// do not report success
Console.out.println("Version: " + BuildInfo.version)
Console.out.println(version())
FAILURE
case _: org.rogach.scallop.exceptions.ScallopException =>
......
......@@ -61,7 +61,9 @@ class TacklerCliArgs(args: Seq[String]) extends ScallopConf(args) {
ConfigFactory.parseMap(JavaConverters.mapAsJavaMap(optsAsMap))
}
version("Version: " + BuildInfo.version)
version(TacklerCli.version())
banner("Tackler CLI is accounting tool for text based double entry accounting.")
/**
* Pure CLI-args (e.g. these don't have a setting in Config)
......
......@@ -73,6 +73,11 @@ class TacklerCliArgsTest extends FunSpec {
}
}
it("checked yes-no for Modified-status") {
assert(TacklerCli.yesno(true) === "Yes")
assert(TacklerCli.yesno(false) === "No")
}
it("reject unknown args") {
assertThrows[UnknownOption] {
TacklerCli.runExceptions(Array[String]("--not-an-argument"))
......
......@@ -9,6 +9,7 @@ addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.0")
// build & release
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
// QA tools
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0-RC1")
......
......@@ -48,6 +48,7 @@ Build-tools (used to build Tackler):
** link:http://www.scala-js.org/[sbt-scalajs]
** link:https://github.com/portable-scala/sbt-crossproject[sbt-crossproject]
** link:https://github.com/sbt/sbt-assembly[sbt-assembly]
** link:https://github.com/sbt/sbt-git[sbt-git]
** link:https://github.com/xerial/sbt-sonatype[sbt-sonatype]
* QA
** link:https://github.com/scoverage/sbt-scoverage[sbt-scoverage]
......@@ -60,3 +61,4 @@ Ideas and inspiration:
* link:https://github.com/hrj/abandon[Abandon]
* link:http://furius.ca/beancount/[Beancount]
* link:http://hledger.org/[hledger]
......@@ -2,8 +2,6 @@
== Build + tools
* Embedded proper GIT commit + dirty-state flag into build info
== Machinery
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment