GetSourceVersion 631 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. usage() {
  3. echo "usage: $0 <source root>"
  4. echo " Prints the source control revision of the given source directory,"
  5. echo " the exact format of the revision string depends on the source "
  6. echo " control system. If the source control system isn't known, the output"
  7. echo " is empty and the exit code is 1."
  8. exit 1
  9. }
  10. if [ $# != 1 ] || [ ! -d $1 ]; then
  11. usage;
  12. fi
  13. cd $1
  14. if [ -d .svn ]; then
  15. svnversion | sed -e "s#\([0-9]*\)[A-Z]*#\1#"
  16. elif [ -f .git/svn/.metadata ]; then
  17. git svn info | grep 'Revision:' | cut -d: -f2-
  18. elif [ -d .git ]; then
  19. git log -1 --pretty=format:%H
  20. else
  21. exit 1;
  22. fi
  23. exit 0