Skip to content

Instantly share code, notes, and snippets.

@gsarjeant
Created September 22, 2014 23:20
Show Gist options
  • Save gsarjeant/26593d6828d149c77896 to your computer and use it in GitHub Desktop.
Save gsarjeant/26593d6828d149c77896 to your computer and use it in GitHub Desktop.
script to retrieve most recent git commit hash
#! /bin/sh
if (( $# != 1 )); then
echo "Call this script with the name of the environment"
echo "Example: ${0} production"
exit 1
fi
ENVROOT='/etc/puppetlabs/puppet/environments'
GITDIR="${ENVROOT}/${1}/.git"
# check to make sure the env repo exists
if [ -d ${GITDIR} ];
then
git --git-dir ${GITDIR} rev-parse --short HEAD
else
date '+%s'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment