summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-07-29 17:36:23 +0000
committerPaul Phillips <paulp@improving.org>2010-07-29 17:36:23 +0000
commit89925960047a8cd62e65647dab6832e28af6bf3b (patch)
tree4db1e375015bb89578692c208a8899343d67cb55
parentc479dcdd980fa79964636c755cf932c83baf86da (diff)
downloadscala-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.
-rw-r--r--build.xml6
-rw-r--r--project/build/SVN.scala44
-rwxr-xr-xtools/get-git-svn-rev5
-rwxr-xr-xtools/git-get-rev5
4 files changed, 31 insertions, 29 deletions
diff --git a/build.xml b/build.xml
index 62fa2ce01f..d6edf7cab1 100644
--- a/build.xml
+++ b/build.xml
@@ -231,11 +231,7 @@ INITIALISATION
<equals arg1="${svn.number.svn}" arg2="0" />
<then>
<!-- Finding SVN revision, git style -->
- <exec osfamily="unix" executable="tools/git-get-rev" outputproperty="svn.number.git" failifexecutionfails="false" />
- <propertyregex
- property="svn.number" input="${svn.number.git}" select="\1"
- regexp="\D*?(\d+)"
- defaultValue="0"/>
+ <exec osfamily="unix" executable="tools/get-git-svn-rev" outputproperty="svn.number" failifexecutionfails="false" />
</then>
<else>
<property name="svn.number" value="${svn.number.svn}" />
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
diff --git a/tools/get-git-svn-rev b/tools/get-git-svn-rev
new file mode 100755
index 0000000000..283b4141fe
--- /dev/null
+++ b/tools/get-git-svn-rev
@@ -0,0 +1,5 @@
+#!/bin/sh
+#
+
+GIT_PAGER=cat
+git log -10 | grep git-svn-id | head -1 | sed 's/[^@]*@\([0-9]*\).*/\1/' \ No newline at end of file
diff --git a/tools/git-get-rev b/tools/git-get-rev
deleted file mode 100755
index 9adda35ca7..0000000000
--- a/tools/git-get-rev
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-#
-
-GIT_PAGER=cat
-git log -10 | grep git-svn-id | head -1 \ No newline at end of file