get-git-version 426 B

123456789101112131415161718
  1. #!/bin/sh
  2. if test -d .git; then
  3. git=`command -v git`
  4. if test -x "$git"; then
  5. version=`git describe --abbrev=6 --dirty --always`
  6. echo "echo $version" > ./version
  7. else
  8. echo "Error: *** git not found. See http://git-scm.com/"
  9. exit 1
  10. fi
  11. elif test -s ./version; then
  12. version=`sh -c ". ./version"`
  13. else
  14. echo "Error: *** invalid tree. Neither '.git' nor 'version' were found"
  15. exit 1
  16. fi
  17. echo -n $version