Skip to content

Instantly share code, notes, and snippets.

@s6577t
Created January 29, 2013 10:15
Show Gist options
  • Select an option

  • Save s6577t/4663236 to your computer and use it in GitHub Desktop.

Select an option

Save s6577t/4663236 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
commit_msg = File.read(ARGV[0])
unless /\A\[#\d+\].*/m.match(commit_msg)
puts 'Commit message rejected by commit-msg git hook because it does not start with a story id. Valid example: "[#123456789] make it so"'
exit -1
end
@s6577t
Copy link
Author

s6577t commented Jan 29, 2013

put this in .git/hooks/ in a file called commit-msg, which will need execute permissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment