Skip to content

Instantly share code, notes, and snippets.

View NickLarsen's full-sized avatar
🏠
Working from home

Nicholas Larsen NickLarsen

🏠
Working from home
View GitHub Profile
@mcgwiz
mcgwiz / pre-commit
Last active November 28, 2018 08:49
Simple git pre-commit hook for detecting a do-not-commit token (e.g. "NOSHARE").
#!/bin/sh
git diff-index --cached --quiet HEAD
_ANY=$?
if ((0 == $_ANY)); then
exit 0
fi
_TOKEN_FOUND=`git diff --cached --name-only | xargs -L1 -I{} sh -c "echo {}; git diff --cached {} | grep -v '^-' | grep -H NOSHARE"`