alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (get-scala-revision)

This example Scala source code file (get-scala-revision) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

dir, dir, figures, git_pager=cat, git_pager=cat, if, revision, revision, usage, usage

The Scala get-scala-revision source code

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

cd $DIR

if [ -d .svn ]; then
  # 2>&1 to catch also error output (e.g. svn warnings)
  svn info . 2>&1 | 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

Other Scala examples (source code examples)

Here is a short list of links related to this Scala get-scala-revision source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.