Created
September 22, 2014 23:20
-
-
Save gsarjeant/26593d6828d149c77896 to your computer and use it in GitHub Desktop.
script to retrieve most recent git commit hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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