Slaying dragons with git, bash, and ruby
rubypond.com
rubypond.com
#!/bin/sh
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
if git diff --cached --diff-filter=AM $against -U0 |
grep "require 'ruby-debug'; debugger" > /dev/null
then
echo "Error: You twit, you've left a debugger in!"
exit 1
fi test "master" == "$(git rev-parse --abbrev-ref HEAD)"
And probably not by grep'ing the output of symbolic-ref.Again, for stuff like this, take a look at git itself. Some fairly major parts of it (such as rebase) are still shell scripts, and the stuff that's once was shell scripts can be found in git.git/contrib/examples
git log -i -E --grep='[[:<:]]wip[[:>:]]' @{upstream}..
You'll notice I also grep'ed for "wip" (as a stand-alone word) with log itself, though this matches anywhere in the commit message, not just the subject. Add --author to this if you like, and maybe --oneline | grep '...' if you further want to grep to just the subject.The git man pages are a decent reference for this kind of stuff.
Given the catching the debug statement is limited to my very specific usage, your suggestion would be more suitable.
I'd like someone else to make up my mind on this. Please discredit the env approach in any way possible :-)
I've also never had an issue with env itself not being where I expect it, but if I ever do I think a symlink addition would solve the problem.
That can't be what was intended ...
More: http://blog.brycekerley.net/post/1082060161/pre-commit-hooks... (and http://news.ycombinator.com/item?id=1669583 )
Any "failing" tests in your workflow would be marked as pending rather than actually failing.
Personally, I'd much rather have something prompt me and say "you're about to push to a remote master from a feature branch, are you sure you want to do this?" rather than using a new set of high-level abstractions such like 'git make-release'.