diff options
author | Bartosz Krasiński <bartosz@krasinski.biz> | 2016-11-12 20:58:31 +0100 |
---|---|---|
committer | Bartosz Krasiński <bartosz@krasinski.biz> | 2016-11-12 21:15:11 +0100 |
commit | 209fc4c7b68db69103630ff87c90f840afe7d1c1 (patch) | |
tree | 01b1b3faf1acb61121bef3280e8ed7f5c2ce1035 /src | |
parent | c4f2024188bc7410e1365d0c54b1a04e41a662ff (diff) | |
download | dotty-209fc4c7b68db69103630ff87c90f840afe7d1c1.tar.gz dotty-209fc4c7b68db69103630ff87c90f840afe7d1c1.tar.bz2 dotty-209fc4c7b68db69103630ff87c90f840afe7d1c1.zip |
Report git-hash used to package the distribution - Closes #1319
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/repl/InterpreterLoop.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/repl/ManifestInfo.scala | 20 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/repl/InterpreterLoop.scala b/src/dotty/tools/dotc/repl/InterpreterLoop.scala index 8b1000f2e..b3ac41c55 100644 --- a/src/dotty/tools/dotc/repl/InterpreterLoop.scala +++ b/src/dotty/tools/dotc/repl/InterpreterLoop.scala @@ -66,7 +66,8 @@ class InterpreterLoop(compiler: Compiler, config: REPL.Config)(implicit ctx: Con output.flush() } - val version = ".next (pre-alpha)" + val gitHash = ManifestInfo.attributes.getOrElse("Git-Hash", "unknown") + val version = s".next (pre-alpha, git-hash: $gitHash)" /** The main read-eval-print loop for the interpreter. It calls * `command()` for each line of input. diff --git a/src/dotty/tools/dotc/repl/ManifestInfo.scala b/src/dotty/tools/dotc/repl/ManifestInfo.scala new file mode 100644 index 000000000..206dccd67 --- /dev/null +++ b/src/dotty/tools/dotc/repl/ManifestInfo.scala @@ -0,0 +1,20 @@ +package dotty.tools.dotc.repl + +import java.net.JarURLConnection +import scala.collection.JavaConversions._ + +object ManifestInfo { + + val attributes: Map[String, String] = { + for { + resourceUrl <- Option(getClass.getResource(getClass.getSimpleName + ".class")) + urlConnection = resourceUrl.openConnection() if urlConnection.isInstanceOf[JarURLConnection] + manifest <- Option(urlConnection.asInstanceOf[JarURLConnection].getManifest) + } yield { + manifest.getMainAttributes.foldLeft(Map[String, String]())( + (map, attribute) => map + (attribute._1.toString -> attribute._2.toString) + ) + } + }.getOrElse(Map()) + +} |