Skip to content

Instantly share code, notes, and snippets.

@marceloandrader
Created May 17, 2011 17:15
Show Gist options
  • Save marceloandrader/976881 to your computer and use it in GitHub Desktop.
Save marceloandrader/976881 to your computer and use it in GitHub Desktop.
commit-msg for xtimes
#!/usr/bin/env ruby
# Author: Marcelo Andrade
# this hook check the validity of a commit message in the format we
# can input to xtimes to create a valid event tagged with the tasks
# we are working on
# INSTALLATION
# Copy this file in each repo in the hooks directory and give execution permission:
# cd your-repo
# cp commit-msg .git/hooks
# chmod u+x .git/hooks/commit-msg
commit_message_tmp_file = ARGV[0]
message = ''
File.open(commit_message_tmp_file, "r") do |infile|
while (line = infile.gets)
message += line
end
end
xtimes_message_format = /(.*)\[(.*)\]/m
if message =~ xtimes_message_format
# the current message match the xtimes format just exit with 0
# allowing git to continue the commit
exit(0)
else
puts "The commit was aborted!!!"
puts "Please use the xtimes message format:"
puts ""
puts " commit message description [tag1, tag2]"
puts ""
exit(1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment