From a00a972c7425232432364bf991e118d248578f0d Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Wed, 8 Jun 2016 10:50:38 +0200 Subject: Add date and hash to publishing version --- project/VersionUtil.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 project/VersionUtil.scala (limited to 'project/VersionUtil.scala') diff --git a/project/VersionUtil.scala b/project/VersionUtil.scala new file mode 100644 index 000000000..338cf2d95 --- /dev/null +++ b/project/VersionUtil.scala @@ -0,0 +1,18 @@ +import scala.sys.process.Process + +object VersionUtil { + def executeScript(scriptName: String) = { + val cmd = + if (System.getProperty("os.name").toLowerCase.contains("windows")) + s"cmd.exe /c scripts\\build\\$scriptName.bat -p" + else s"scripts/build/$scriptName" + Process(cmd).lines.head.trim + } + + /** Seven letters of the SHA hash is considered enough to uniquely identify a + * commit, albeit extremely large projects - such as the Linux kernel - need + * more letters to stay unique + */ + def gitHash = executeScript("get-scala-commit-sha").substring(0, 7) + def commitDate = executeScript("get-scala-commit-date") +} -- cgit v1.2.3