File tree Expand file tree Collapse file tree 6 files changed +74
-2
lines changed Expand file tree Collapse file tree 6 files changed +74
-2
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,8 @@ object DottyBuild extends Build {
25
25
override def settings : Seq [Setting [_]] = {
26
26
super .settings ++ Seq (
27
27
scalaVersion in Global := " 2.11.5" ,
28
- version in Global := " 0.1-SNAPSHOT" ,
28
+ version in Global :=
29
+ " 0.1-SNAPSHOT-" + VersionUtil .commitDate + " -" + VersionUtil .gitHash,
29
30
organization in Global := " ch.epfl.lamp" ,
30
31
organizationName in Global := " LAMP/EPFL" ,
31
32
organizationHomepage in Global := Some (url(" http://lamp.epfl.ch" )),
@@ -208,7 +209,8 @@ object DottyBuild extends Build {
208
209
" org.scala-sbt" % " api" % sbtVersion.value % " test" ,
209
210
" org.specs2" %% " specs2" % " 2.3.11" % " test"
210
211
),
211
- version := " 0.1.1-SNAPSHOT" ,
212
+ version :=
213
+ " 0.1.1-SNAPSHOT-" + VersionUtil .commitDate + " -" + VersionUtil .gitHash,
212
214
// The sources should be published with crossPaths := false, the binaries
213
215
// are unused so it doesn't matter.
214
216
crossPaths := false ,
Original file line number Diff line number Diff line change
1
+ import scala .sys .process .Process
2
+
3
+ object VersionUtil {
4
+ def executeScript (scriptName : String ) = {
5
+ val cmd =
6
+ if (System .getProperty(" os.name" ).toLowerCase.contains(" windows" ))
7
+ s " cmd.exe /c scripts \\ build \\ $scriptName.bat -p "
8
+ else s " scripts/build/ $scriptName"
9
+ Process (cmd).lines.head.trim
10
+ }
11
+
12
+ /** Seven letters of the SHA hash is considered enough to uniquely identify a
13
+ * commit, albeit extremely large projects - such as the Linux kernel - need
14
+ * more letters to stay unique
15
+ */
16
+ def gitHash = executeScript(" get-scala-commit-sha" ).substring(0 , 7 )
17
+ def commitDate = executeScript(" get-scala-commit-date" )
18
+ }
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ #
3
+ # Usage: get-scala-commit-date [dir]
4
+ # Figures out current commit date of a git clone.
5
+ # If no dir is given, current working dir is used.
6
+ #
7
+ # Example build version string:
8
+ # 20120312
9
+ #
10
+
11
+ [[ $# -eq 0 ]] || cd " $1 "
12
+
13
+ lastcommitdate=$( git log --format=" %ci" HEAD | head -n 1 | cut -d ' ' -f 1)
14
+
15
+ # 20120324
16
+ echo " ${lastcommitdate// -/ } "
Original file line number Diff line number Diff line change
1
+ @ echo off
2
+ for %%X in (bash.exe) do (set FOUND=%%~$PATH:X )
3
+ if defined FOUND (
4
+ bash " %~dp0 \get-scala-commit-date" 2 > NUL
5
+ ) else (
6
+ rem echo this script does not work with cmd.exe. please, install bash
7
+ echo unknown
8
+ exit 1
9
+ )
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ #
3
+ # Usage: get-scala-commit-sha [dir]
4
+ # Figures out current commit sha of a git clone.
5
+ # If no dir is given, current working dir is used.
6
+ #
7
+ # Example build version string:
8
+ # 6f1c486d0ba
9
+ #
10
+
11
+ [[ $# -eq 0 ]] || cd " $1 "
12
+
13
+ # printf %016s is not portable for 0-padding, has to be a digit.
14
+ # so we're stuck disassembling it.
15
+ hash=$( git log -1 --format=" %H" HEAD)
16
+ hash=${hash# g}
17
+ hash=${hash: 0: 10}
18
+ echo " $hash "
Original file line number Diff line number Diff line change
1
+ @ echo off
2
+ for %%X in (bash.exe) do (set FOUND=%%~$PATH:X )
3
+ if defined FOUND (
4
+ bash " %~dp0 \get-scala-commit-sha" 2 > NUL
5
+ ) else (
6
+ rem echo this script does not work with cmd.exe. please, install bash
7
+ echo unknown
8
+ exit 1
9
+ )
You can’t perform that action at this time.
0 commit comments