#!/bin/sh
set -e

if [ -z "$GOPACKAGE" ]; then
    # not being run from 'go generate'
    cd "$(dirname "$0")"/cmd
fi

v="$( git describe --dirty --always | sed -e 's/-/+git/;y/-/./' )"

cat <<EOF > version_generated.go
// generated by mkversion.sh; do not edit
package cmd

func init() {
	Version = "$v"
}
EOF
