diff options
author | Paul Phillips <paulp@improving.org> | 2010-07-29 17:36:23 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-07-29 17:36:23 +0000 |
commit | 89925960047a8cd62e65647dab6832e28af6bf3b (patch) | |
tree | 4db1e375015bb89578692c208a8899343d67cb55 /project/build | |
parent | c479dcdd980fa79964636c755cf932c83baf86da (diff) | |
download | scala-89925960047a8cd62e65647dab6832e28af6bf3b.tar.gz scala-89925960047a8cd62e65647dab6832e28af6bf3b.tar.bz2 scala-89925960047a8cd62e65647dab6832e28af6bf3b.zip |
Alterations so the sbt build will run under git...
Alterations so the sbt build will run under git-svn. Review by moix.
Diffstat (limited to 'project/build')
-rw-r--r-- | project/build/SVN.scala | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/project/build/SVN.scala b/project/build/SVN.scala index 78624f3ba7..e05c949587 100644 --- a/project/build/SVN.scala +++ b/project/build/SVN.scala @@ -6,29 +6,35 @@ import scala.util.matching.{Regex} * @param root the root of an svn repository * @author Moix Grégory */ -class SVN(root:Path){ +class SVN(root: Path) { + /** Location of tool which parses svn revision in git-svn repository. */ + val GitSvnRevTool = root / "tools" / "get-git-svn-rev" /** * 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 - } + def getRevisionNumber: Int = getSvn orElse getGit getOrElse { + throw new UnableToGetRevisionNumberException + } + def getSvn: Option[Int] = { + val svnInfo = Process("svn info", root) + 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 map (_.group("version").toInt) + } + else None + } + + def getGit: Option[Int] = + try { Some(Process(GitSvnRevTool.toString, root).!!.trim.toInt) } + catch { case _: Exception => None } } + class UnableToGetRevisionNumberException extends RuntimeException
\ No newline at end of file |