version.sh 299 B

12345678910
  1. #!/bin/sh
  2. hash=$(git --git-dir="$(dirname $0)/.git" rev-parse --short HEAD 2>/dev/null)
  3. branch=$(git --git-dir="$(dirname $0)/.git" rev-parse --abbrev-ref HEAD | sed -r 's/.*[^0-9A-Za-z-]([0-9A-Za-z-]*)$/\1/g')
  4. if [ -n "$hash" ] || [ -n "$branch" ]
  5. then
  6. printf '+g%s.%s' "$hash" "$branch"
  7. fi
  8. echo