#!/usr/bin/env ruby def arrow(args) arrow = "===> " if args.respond_to?(:each) puts args.map! { |r| arrow + r }.join("\n") else puts arrow + args end end commit_file = ARGV[0] message = `cat #{commit_file}` # matches either # # "123 - Some Message\n" <-- git puts a \n in there... # # Or # # "123 - Some Message # # Definitely something here # More optional stuff" # message_filter = /\A(\d[\d ,]+) - ([^\n]+)\n(\n+(.+))?\z/m bump_filter = /\ABump version number to ([\d.]+)\n\z/ merge_filter = /\AMerge \w* '(.*)' into (.*)\n\z/ if message_filter.match message exit 0 elsif bump_filter.match message exit 0 elsif merge_filter.match message exit 0 else puts "" arrow "============================================== Enforcing Sentia Commit Message Policy ============================================== Fall in line soldier, correct commit format is - Summary Message o p t i o n a l or Bump version number to x.x.x or Merge branch 'develop' into master where id = trello card/tracker issue id/number eg 456 - Fix user.company nilclass issue with NullCompany or 123 - Add archive post action Add POST posts#archive action Add GET posts#archived action Add 'Archive' button to /posts/:id/edit page Add hide archived posts from GET /posts Add GET /posts/archived route and << views, view styling is changed to make it obvious that the post is archived".split("\n") puts "" exit 1 end