Skip to content

Instantly share code, notes, and snippets.

@kig
Created September 17, 2008 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kig/11252 to your computer and use it in GitHub Desktop.
Save kig/11252 to your computer and use it in GitHub Desktop.
post-commit:
#!/usr/bin/ruby
lastlog = `git log -1`
raise "Error in git log -1" if $?.exitstatus != 0
if lastlog.include?("fix") and not lastlog.include?("closebug")
`echo bug >> bug`
raise "Error in echo" if $?.exitstatus != 0
`git add bug`
raise "Error in git add bug" if $?.exitstatus != 0
`git commit -m closebug`
raise "Error in git commit -m closebug" if $?.exitstatus != 0
end
--- end of post-commit
mkdir test;
cd test;
git init;
chmod 755 ../post-commit;
cp ../post-commit .git/hooks/post-commit;
echo foo >> foo
git add foo
git commit -m 'foo'
echo foo >> foo
git add foo
git commit -m 'fix foo'
git status
# On branch master
#nothing to commit (working directory clean)
echo foo >> foo
git commit -a -m 'fix foo'
git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
#
# modified: bug
#
#no changes added to commit (use "git add" and/or "git commit -a")
git --version
#git version 1.5.3.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment