Last active
October 2, 2020 16:33
-
-
Save hartfordfive/9670011 to your computer and use it in GitHub Desktop.
Revisions
-
hartfordfive renamed this gist
Apr 21, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
hartfordfive revised this gist
Mar 21, 2014 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -15,18 +15,25 @@ while read oldrev newrev refname; do # Get the file names, without directory, of the files that have been modified # between the new revision and the old revision files=`git diff --name-only ${oldrev} ${newrev}` # Get a list of all objects in the new revision objects=`git ls-tree --full-name -r ${newrev}` # Iterate over each of these files for file in ${files}; do # Search for the file name in the list of all objects object=`echo -e "${objects}" | egrep "(\s)${file}\$" | awk '{ print $3 }'` # If it's not present, then continue to the the next itteration if [ -z ${object} ]; then continue; fi # Otherwise, create all the necessary sub directories in the new temp directory mkdir -p "${TEMPDIR}/`dirname ${file}`" &>/dev/null # and output the object content into it's original file name git cat-file blob ${object} > ${TEMPDIR}/${file} done; -
hartfordfive revised this gist
Mar 20, 2014 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,9 +11,17 @@ newrev=$2 refname=$3 while read oldrev newrev refname; do # Get the file names, without directory, of the files that have been modified # between the new revision and the old revision files=`git diff --name-only ${oldrev} ${newrev}` objects=`git ls-tree --full-name -r ${newrev}` # Iterate over each of these files for file in ${files}; do object=`echo -e "${objects}" | egrep "(\s)${file}\$" | awk '{ print $3 }'` if [ -z ${object} ]; then continue; -
hartfordfive created this gist
Mar 20, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ #!/bin/bash COMMAND='puppet parser validate' TEMPDIR=`mktemp -d` echo "### Attempting to validate puppet files... ####" # See https://www.kernel.org/pub/software/scm/git/docs/githooks.html#pre-receive oldrev=$1 newrev=$2 refname=$3 while read oldrev newrev refname; do files=`git diff --name-only ${oldrev} ${newrev}` for file in ${files}; do object=`git ls-tree --full-name -r ${newrev} | egrep "(\s)${file}\$" | awk '{ print $3 }'` if [ -z ${object} ]; then continue; fi mkdir -p "${TEMPDIR}/`dirname ${file}`" &>/dev/null git cat-file blob ${object} > ${TEMPDIR}/${file} done; done # Now loop over each file in the temp dir to parse them for valid syntax files_found=`find ${TEMPDIR} -name '*.pp'` for fname in ${files_found}; do ${COMMAND} ${fname} if [[ $? -ne 0 ]]; then echo "ERROR: parser failed on ${fname}" bad_file=1 fi done; rm -rf ${TEMPDIR} &> /dev/null if [[ $bad_file -eq 1 ]] then exit 1 fi