Sha256: 7d72862d965b99224b029f11c913cf61457326416aa3396e3ddf77f98fcceddc

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

#!/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

     <id or ids> - Summary Message
o    <newline>
p    <Specific Message>
t    <Specific Message>
i    <Specific Message>
o    <Specific Message>
n    <Specific Message>
a    <Specific Message>
l    <Specific Message>

 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sentia_git_hooks-0.2.0 lib/scripts/commit-msg