git-version 363 B

123456789101112131415161718192021
  1. #!/bin/bash
  2. version='v0.1.2'
  3. if test -d .git
  4. then
  5. gv=`git describe`
  6. if [[ "$?" == "0" ]]
  7. then
  8. if [[ "$(echo "${gv}" | cut -d'-' -f1)" != "$version" ]]
  9. then
  10. echo "$0 has mismatched version" >&2
  11. echo "${gv}-ERROR"
  12. exit 1
  13. fi
  14. version="$(echo ${gv} | cut -c2-)"
  15. fi
  16. fi
  17. echo "${version}"