#!/usr/bin/env bash
# show a version string of the repo
vstr=`git describe --long 2> /dev/null`

if [ "$1" == "--commit-only" ] ; then
  case "$vstr" in
  v[0-9]*)
    vstr=`echo $vstr | cut -f3 -d- | cut -b2-`
    ;;
  *) vstr="tarball"
  esac
else
  case "$vstr" in
  v[0-9]*)
    git update-index -q --refresh 2> /dev/null
    test -z "`git diff-index --name-only HEAD -- 2>&1`" || vstr="$vstr-dirty"
    ;;
  *) vstr="tarball"
  esac
fi

echo $vstr
