summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-11-26 23:53:37 +0000
committerPaul Phillips <paulp@improving.org>2010-11-26 23:53:37 +0000
commitbb3235a2b6f5521040e96da30a6cf122940cd539 (patch)
tree3927674760b84f5a9587867649d5da51f51983de
parent72d12aabf35f699ef103d79f29f8f7b21286d94c (diff)
downloadscala-bb3235a2b6f5521040e96da30a6cf122940cd539.tar.gz
scala-bb3235a2b6f5521040e96da30a6cf122940cd539.tar.bz2
scala-bb3235a2b6f5521040e96da30a6cf122940cd539.zip
Moved the painful-in-ant git/svn revision getti...
Moved the painful-in-ant git/svn revision getting logic into bash where it's at least somewhat less painful. Made it more flexible for easy use in more places since we presently have all kinds of revision figuring logic variations in other build files (sbaz, installer, scala-documentation, scala-tool-support, etc.) No review.
-rw-r--r--build.xml25
-rwxr-xr-xtools/get-git-svn-rev28
-rwxr-xr-xtools/get-scala-revision29
3 files changed, 59 insertions, 23 deletions
diff --git a/build.xml b/build.xml
index e7d4fad6c5..f5b3571994 100644
--- a/build.xml
+++ b/build.xml
@@ -221,27 +221,10 @@ INITIALISATION
<condition property="os.win">
<os family="windows"/>
</condition>
- <!-- Finding out SVN revision, svn style -->
- <exec executable="svn" outputproperty="svn.out"
- failifexecutionfails="false">
- <arg line=" info ${basedir}"/>
- </exec>
- <propertyregex
- property="svn.number.svn" input="${svn.out}" select="\1"
- regexp="Revision: ([0-9]+)"
- defaultValue="0"/>
-
- <!-- Both clauses of the conditional set svn.number -->
- <if>
- <equals arg1="${svn.number.svn}" arg2="0" />
- <then>
- <!-- Finding SVN revision, git style -->
- <exec osfamily="unix" executable="tools/get-git-svn-rev" outputproperty="svn.number" failifexecutionfails="false" />
- </then>
- <else>
- <property name="svn.number" value="${svn.number.svn}" />
- </else>
- </if>
+
+ <exec osfamily="unix" executable="tools/get-scala-revision" outputproperty="svn.number" failifexecutionfails="false" />
+ <!-- some default in case something went wrong getting the revision -->
+ <property name="svn.number" value="0"/>
<property name="init.avail" value="yes"/>
diff --git a/tools/get-git-svn-rev b/tools/get-git-svn-rev
index 283b4141fe..0fa020de95 100755
--- a/tools/get-git-svn-rev
+++ b/tools/get-git-svn-rev
@@ -1,5 +1,29 @@
#!/bin/sh
#
+# Usage: get-scala-rev [dir]
+# Figures out current scala revision of an svn checkout or
+# a git-svn mirror (or a git clone.)
+#
+# If no dir is given, current working dir is used.
+
+DIR=""
+if [[ $# -eq 0 ]]; then
+ DIR=`pwd`
+else
+ DIR=$1
+fi
+
+builtin cd $DIR
-GIT_PAGER=cat
-git log -10 | grep git-svn-id | head -1 | sed 's/[^@]*@\([0-9]*\).*/\1/' \ No newline at end of file
+if [[ -d .svn ]]; then
+ svn info . | grep ^Revision | sed 's/Revision: //'
+elif [[ -d .git ]]; then
+ GIT_PAGER=cat
+ # this grabs more than one line because otherwise if you have local
+ # commits which aren't in git-svn it won't see any revision.
+ git log -10 | grep git-svn-id | head -1 | sed 's/[^@]*@\([0-9]*\).*/\1/'
+else
+ echo "${DIR} doesn't appear to be git or svn dir." >&2
+ echo 0
+ exit 1
+fi
diff --git a/tools/get-scala-revision b/tools/get-scala-revision
new file mode 100755
index 0000000000..0fa020de95
--- /dev/null
+++ b/tools/get-scala-revision
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+# Usage: get-scala-rev [dir]
+# Figures out current scala revision of an svn checkout or
+# a git-svn mirror (or a git clone.)
+#
+# If no dir is given, current working dir is used.
+
+DIR=""
+if [[ $# -eq 0 ]]; then
+ DIR=`pwd`
+else
+ DIR=$1
+fi
+
+builtin cd $DIR
+
+if [[ -d .svn ]]; then
+ svn info . | grep ^Revision | sed 's/Revision: //'
+elif [[ -d .git ]]; then
+ GIT_PAGER=cat
+ # this grabs more than one line because otherwise if you have local
+ # commits which aren't in git-svn it won't see any revision.
+ git log -10 | grep git-svn-id | head -1 | sed 's/[^@]*@\([0-9]*\).*/\1/'
+else
+ echo "${DIR} doesn't appear to be git or svn dir." >&2
+ echo 0
+ exit 1
+fi