summaryrefslogblamecommitdiff
path: root/tools/get-git-svn-rev
blob: 0fa020de9568a1d9b49f02d71173aed7170b55fb (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

         













                                                          
 











                                                                          
#!/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