Skip to content

Instantly share code, notes, and snippets.

@s7v7nislands
Created July 1, 2014 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s7v7nislands/8ff45a1adecbc52ba857 to your computer and use it in GitHub Desktop.
Save s7v7nislands/8ff45a1adecbc52ba857 to your computer and use it in GitHub Desktop.
generate git version
#!/bin/bash
VER=`git rev-list --count HEAD`
if git status | grep -q "modified:" ; then
VER="${VER}M"
fi
VER="$VER_$(git rev-parse --head HEAD)"
GIT_VERSION=r$VER
cat > version.go << EOF
package main
const version = $VER_$GIT_VERSION
EOF
echo "Generated version.go"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment