1*87b8faf2SDaniel Dunbar#!/bin/sh 2*87b8faf2SDaniel Dunbar 3*87b8faf2SDaniel Dunbarfunction usage() { 4*87b8faf2SDaniel Dunbar echo "usage: $0 <source root>" 5*87b8faf2SDaniel Dunbar echo " Prints the source control revision of the given source directory," 6*87b8faf2SDaniel Dunbar echo " the exact format of the revision string depends on the source " 7*87b8faf2SDaniel Dunbar echo " control system. If the source control system isn't known, the output" 8*87b8faf2SDaniel Dunbar echo " is empty and the exit code is 1." 9*87b8faf2SDaniel Dunbar exit 1 10*87b8faf2SDaniel Dunbar} 11*87b8faf2SDaniel Dunbar 12*87b8faf2SDaniel Dunbarif [ $# != 1 ] || [ ! -d $1 ]; then 13*87b8faf2SDaniel Dunbar usage; 14*87b8faf2SDaniel Dunbarfi 15*87b8faf2SDaniel Dunbar 16*87b8faf2SDaniel Dunbarcd $1 17*87b8faf2SDaniel Dunbarif [ -d .svn ]; then 18*87b8faf2SDaniel Dunbar svnversion 19*87b8faf2SDaniel Dunbarelif [ -d .git/svn ]; then 20*87b8faf2SDaniel Dunbar git svn info | grep 'Revision:' | cut -d: -f2- 21*87b8faf2SDaniel Dunbarelif [ -d .git ]; then 22*87b8faf2SDaniel Dunbar git log -1 --pretty=format:%H 23*87b8faf2SDaniel Dunbarelse 24*87b8faf2SDaniel Dunbar exit 1; 25*87b8faf2SDaniel Dunbarfi 26*87b8faf2SDaniel Dunbar 27*87b8faf2SDaniel Dunbarexit 0 28