187b8faf2SDaniel Dunbar#!/bin/sh 287b8faf2SDaniel Dunbar 3b33a43b5SDaniel Dunbarusage() { 487b8faf2SDaniel Dunbar echo "usage: $0 <source root>" 587b8faf2SDaniel Dunbar echo " Prints the source control revision of the given source directory," 687b8faf2SDaniel Dunbar echo " the exact format of the revision string depends on the source " 787b8faf2SDaniel Dunbar echo " control system. If the source control system isn't known, the output" 887b8faf2SDaniel Dunbar echo " is empty and the exit code is 1." 987b8faf2SDaniel Dunbar exit 1 1087b8faf2SDaniel Dunbar} 1187b8faf2SDaniel Dunbar 1287b8faf2SDaniel Dunbarif [ $# != 1 ] || [ ! -d $1 ]; then 1387b8faf2SDaniel Dunbar usage; 1487b8faf2SDaniel Dunbarfi 1587b8faf2SDaniel Dunbar 1687b8faf2SDaniel Dunbarcd $1 1787b8faf2SDaniel Dunbarif [ -d .svn ]; then 188211d310SDaniel Dunbar svnversion | sed -e "s#\([0-9]*\)[A-Z]*#\1#" 19*bf0bf743SDaniel Dunbarelif [ -f .git/svn/.metadata ]; then 2087b8faf2SDaniel Dunbar git svn info | grep 'Revision:' | cut -d: -f2- 2187b8faf2SDaniel Dunbarelif [ -d .git ]; then 2287b8faf2SDaniel Dunbar git log -1 --pretty=format:%H 2387b8faf2SDaniel Dunbarelse 2487b8faf2SDaniel Dunbar exit 1; 2587b8faf2SDaniel Dunbarfi 2687b8faf2SDaniel Dunbar 2787b8faf2SDaniel Dunbarexit 0 28