summaryrefslogtreecommitdiff
path: root/project/build/SVN.scala
diff options
context:
space:
mode:
authormoix <moix@epfl.ch>2010-07-29 09:52:28 +0000
committermoix <moix@epfl.ch>2010-07-29 09:52:28 +0000
commite3ca222e48fa917d631c1ee6ecbc8a594ae76d10 (patch)
treec5c719ee1b38d5f238ee513279fda4f8cb263283 /project/build/SVN.scala
parent26bbdbe3a21d17f5b2a94ea528eb4508d2b3b13e (diff)
downloadscala-e3ca222e48fa917d631c1ee6ecbc8a594ae76d10.tar.gz
scala-e3ca222e48fa917d631c1ee6ecbc8a594ae76d10.tar.bz2
scala-e3ca222e48fa917d631c1ee6ecbc8a594ae76d10.zip
First version of SBT build for Scala compiler/l...
First version of SBT build for Scala compiler/library (see README)
Diffstat (limited to 'project/build/SVN.scala')
-rw-r--r--project/build/SVN.scala34
1 files changed, 34 insertions, 0 deletions
diff --git a/project/build/SVN.scala b/project/build/SVN.scala
new file mode 100644
index 0000000000..78624f3ba7
--- /dev/null
+++ b/project/build/SVN.scala
@@ -0,0 +1,34 @@
+import sbt._
+import java.io.{ByteArrayOutputStream}
+import scala.util.matching.{Regex}
+
+/**
+ * @param root the root of an svn repository
+ * @author Moix Grégory
+ */
+class SVN(root:Path){
+
+ /**
+ * Gets the revision number of the repository given through the constructor of the class
+ * It assumes that svn is installed on the running computer.
+ */
+ def getRevisionNumber:Int = {
+ val svnInfo = Process("svn info", root)
+ var result=0
+ val out= new ByteArrayOutputStream
+ val code:Int = svnInfo.#>(out).!
+ if(code == 0) {
+ val r = out.toString
+ val Pattern = new Regex("""Revision: (\d+)""","version")
+ val version = Pattern.findFirstMatchIn(r)
+ version match {
+ case Some(s)=> result=Integer.parseInt(s.group("version"))
+ case None => throw new UnableToGetRevisionNumberException
+ }
+ } else {
+ throw new UnableToGetRevisionNumberException
+ }
+ result
+ }
+}
+class UnableToGetRevisionNumberException extends RuntimeException \ No newline at end of file