2010-01-21 16:09:59 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-01-22 18:14:21 +00:00
|
|
|
usage() {
|
2010-09-29 17:57:01 +00:00
|
|
|
echo "usage: $0 <source root>"
|
|
|
|
echo " Prints the source control revision of the given source directory,"
|
|
|
|
echo " the exact format of the revision string depends on the source "
|
|
|
|
echo " control system. If the source control system isn't known, the output"
|
|
|
|
echo " is empty and the exit code is 1."
|
|
|
|
exit 1
|
2010-01-21 16:09:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# != 1 ] || [ ! -d $1 ]; then
|
|
|
|
usage;
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $1
|
|
|
|
if [ -d .svn ]; then
|
2010-09-29 19:30:17 +00:00
|
|
|
svnversion | sed -e "s#\([0-9]*\)[A-Z]*#\1#"
|
2012-05-15 18:44:09 +00:00
|
|
|
elif [ -f .git/svn/.metadata ]; then
|
2010-09-29 17:57:01 +00:00
|
|
|
git svn info | grep 'Revision:' | cut -d: -f2-
|
2010-01-21 16:09:59 +00:00
|
|
|
elif [ -d .git ]; then
|
2010-09-29 17:57:01 +00:00
|
|
|
git log -1 --pretty=format:%H
|
2010-01-21 16:09:59 +00:00
|
|
|
else
|
2010-09-29 17:57:01 +00:00
|
|
|
exit 1;
|
2010-01-21 16:09:59 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|