-
-
Save JJ/766a982621a1c1c7455f to your computer and use it in GitHub Desktop.
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/bash -l | |
# A git hook script to find and fix trailing whitespace | |
# in your commits. Bypass it with the --no-verify option | |
# to git-commit | |
# | |
.git/hooks/pre-commit-master-no-no | |
if [[ $? == 1 ]] | |
then | |
exit 1 | |
fi | |
.git/hooks/pre-commit-debugger | |
.git/hooks/pre-commit-trailing-spaces | |
.git/hooks/pre-commit-images | |
.git/hooks/pre-commit-pair |
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 | |
# Originally from http://mark-story.com/posts/view/using-git-commit-hooks-to-prevent-stupid-mistakes, | |
# but does not work now and can be simplified | |
if git rev-parse --verify HEAD >/dev/null 2>&1; then | |
against=HEAD | |
else | |
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 | |
fi | |
for FILE in `git diff-index --name-only $against` ; do | |
# Check if the file contains 'debugger' | |
echo $FILE $against | |
if [ "grep 'debugger' $FILE" ] | |
then | |
echo $FILE ' contains debugger!' | |
exit 1 | |
fi | |
done | |
exit |
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/bash -l | |
echo "Optimizing images" | |
# Find image files and optimize them | |
for FILE in `exec git diff --cached --name-status | grep ".png$" | awk '$1 != "R" { print $2 }'`; do | |
echo "Optimizing $FILE" | |
bundle exec smusher $FILE | |
git add "$FILE" | |
done |
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/bash | |
#Hook to verify that comments are not done to the master branch accidentally | |
#Need to check the status and exit the hook if this script exits with a non-zero code | |
#.git/hooks/pre-commit-master-no-no | |
#if [[ $? == 1 ]] | |
#then | |
# exit 1 | |
#fi | |
if [[ `git symbolic-ref HEAD` == "refs/heads/master" ]] | |
then | |
if [[ ! -f /tmp/master_commit ]] | |
then | |
echo "*************************" | |
echo "CANNOT COMMIT TO MASTER!" | |
echo "To override this behavior" | |
echo "touch /tmp/master_commit" | |
echo "*************************" | |
exit 1 | |
else | |
echo "Removing /tmp/master_commit" | |
rm /tmp/master_commit | |
fi | |
fi |
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/bash | |
#Really, I don't know what this did originally. didn't make too much sense | |
echo `git var -l |grep user` |
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/bash | |
echo "Remove trailing spaces" | |
if git rev-parse --verify HEAD >/dev/null 2>&1 ; then | |
against=HEAD | |
else | |
# Initial commit: diff against an empty tree object | |
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 | |
fi | |
echo $against | |
# Find files with trailing whitespace | |
for FILE in `exec git diff-index --check $against -- | sed '/^[+-]/d' | (sed -r 's/:[0-9]+:.*//' > /dev/null 2>&1 || sed -E 's/:[0-9]+:.*//') | uniq` ; do | |
# Fix them! | |
echo $FILE | |
(sed -i 's/[[:space:]]*$//' "$FILE" > /dev/null 2>&1 || sed -i '' -E 's/[[:space:]]*$//' "$FILE") | |
git add "$FILE" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment