make_version 593 B

12345678910111213141516171819202122
  1. #!/bin/sh
  2. if [ -f ${1}/.version ]; then
  3. cat ${1}/.version
  4. elif [ -d ${1}/.git ]; then
  5. VERSION=`git describe --tags --dirty=M 2> /dev/null | sed -e "s/^v\([0-9]\)/\1/"`
  6. if [ $? -ne 0 ]; then
  7. MODIFIED=""
  8. if [ "`git ls-files -m | wc -l`" != "0" ]; then
  9. MODIFIED="M"
  10. fi
  11. # Some older versions of git do not support all the above
  12. # options.
  13. VERSION=GIT-`git rev-parse --short --verify HEAD`${MODIFIED}
  14. fi
  15. echo ${VERSION}
  16. else
  17. # Use the directory information in the absence of any other version
  18. # information
  19. pwd -P
  20. fi