Permalink
Browse files

Brought version detection up-to-date.

* SBT's version creation is now on par with tools/get-latest-version
  • Loading branch information...
1 parent e596190 commit 971536593f33f357356b4c58d8a66742755801b8 @jsuereth jsuereth committed Dec 16, 2011
Showing with 21 additions and 19 deletions.
  1. +2 −2 project/Layers.scala
  2. +19 −17 project/Release.scala
View
4 project/Layers.scala
@@ -57,7 +57,7 @@ trait Layers extends Build {
// TODO - Allow other scalac option settings.
scalacOptions in Compile <++= (scalaSource in Compile) map (src => Seq("-sourcepath", src.getAbsolutePath)),
classpathOptions := ClasspathOptions.manual,
- resourceGenerators in Compile <+= (baseDirectory, version, resourceManaged, gitRunner) map Release.generatePropertiesFile("library.properties"),
+ resourceGenerators in Compile <+= (baseDirectory, version, resourceManaged, gitRunner, streams) map Release.generatePropertiesFile("library.properties"),
referenceScala
)
@@ -70,7 +70,7 @@ trait Layers extends Build {
defaultExcludes := ("tests"),
javacOptions ++= Seq("-source", "1.4"),
defaultExcludes in unmanagedResources := "*.scala",
- resourceGenerators in Compile <+= (baseDirectory, version, resourceManaged, gitRunner) map Release.generatePropertiesFile("compiler.properties"),
+ resourceGenerators in Compile <+= (baseDirectory, version, resourceManaged, gitRunner, streams) map Release.generatePropertiesFile("compiler.properties"),
// Note, we might be able to use the default task, but for some reason ant was filtering files out. Not sure what's up, but we'll
// stick with that for now.
unmanagedResources in Compile <<= (baseDirectory) map {
View
36 project/Release.scala
@@ -66,11 +66,11 @@ object Release {
/** This generates a properties file, if it does not already exist, with the maximum lastmodified timestamp
* of any source file. */
- def generatePropertiesFile(name: String)(baseDirectory: File, version: String, dir: File, git: GitRunner): Seq[File] = {
+ def generatePropertiesFile(name: String)(baseDirectory: File, version: String, dir: File, git: GitRunner, s: TaskStreams): Seq[File] = {
// TODO - We can probably clean this up by moving caching bits elsewhere perhaps....
val target = dir / name
// TODO - Regenerate on triggers, like recompilation or something...
- val fullVersion = makeFullVersionString(baseDirectory, version, git)
+ val fullVersion = makeFullVersionString(baseDirectory, version, git, s)
def hasSameVersion: Boolean = {
val props = new java.util.Properties
val in = new java.io.FileInputStream(target)
@@ -88,26 +88,28 @@ object Release {
def makePropertiesFile(f: File, version: String): Unit =
IO.write(f, "version.number = "+version+"\ncopyright.string = Copyright 2002-2011, LAMP/EPFL")
- def makeFullVersionString(baseDirectory: File, baseVersion: String, git: GitRunner) = baseVersion+"."+getGitRevision(baseDirectory, git)+"."+currentDay
+ def makeFullVersionString(baseDirectory: File, baseVersion: String, git: GitRunner, s: TaskStreams) = baseVersion+"."+getGitRevision(baseDirectory, git, currentDay, s)
// TODO - do we want this in the build number?
def currentDay = (new java.text.SimpleDateFormat("yyyyMMdd'T'HHmmss")) format (new java.util.Date)
- def getGitRevision(baseDirectory: File, git: GitRunner) = {
- object outputStealer extends sbt.Logger {
- private val stdout = new StringBuilder
- private val stderr = new StringBuilder
- def log (level: Level.Value, message: String): Unit = stdout append message
- def success (message: String): Unit = ()
- def trace (t: Throwable): Unit = ()
- def stdoutString = stdout.toString
- }
- val result = try {
- git("describe", "HEAD", "--abbrev=7", "--match", "dev")(baseDirectory, outputStealer)
- } catch {
- case t => git("describe", "HEAD", "--abbrev=7", "--always")(baseDirectory, outputStealer)
+
+
+ def getGitRevision(baseDirectory: File, git: GitRunner, date: String, s: TaskStreams) = {
+
+ val mergeBase = {
+ // TODO - Cache this value.
+ // git("merge-base","v2.8.2","v2.9.1","master")(baseDirectory, s.log)
+ "df13e31bbb"
}
- result.trim
+ // current commit sha
+ val sha =
+ git("rev-list", "-n", "1", "HEAD")(baseDirectory, s.log)
+
+ val commits =
+ git("--no-pager", "log", "--pretty=oneline", mergeBase +"..HEAD")(baseDirectory, s.log) split "[\r\n]+" size
+
+ "rdev-%d-%s-g%s" format (commits, date, sha.substring(0,7))
}
}

0 comments on commit 9715365

Please sign in to comment.