Skip to content
Snippets Groups Projects
Commit afbd6680 authored by Auke Klazema's avatar Auke Klazema
Browse files

SW-773: Remove one hook and fix the other hook

parent a7b36b96
No related branches found
No related tags found
1 merge request!8Cobalt2 multithreading fix
#! /usr/bin/env ruby
$regex = /^((fixes|task|story|issue)\s)?(#(\d+)|[a-zA-Z]+-(\d)+):/i
# Simple function, just for ease of testing
def parse_message(msg,re)
if not re.match(msg)
return false
else
return true
end
end
# enforced custom commit message format
def check_message_format
missed_revs = `git rev-list #{$rev_old}..#{$rev_new}`.split("\n")
missed_revs.each do |rev|
message = `git cat-file commit #{rev} | sed '1,/^$/d'`
if not parse_message(message,$regex)
STDERR.puts("[pre-receive hook] Your commit #{ rev } was rejected.")
STDERR.puts("[pre-receive hook] Commit message must start with a JIRA task ID,"\
" or \"Task\", \"Story\", \"Issue\" or \"Fixes\", followed by an issue ID.")
STDERR.puts("[pre-receive hook] For example: \"Task #42: Fixed bug\" or \"SW-22334: Fixed bug\"")
STDERR.puts("[pre-receive hook] Your commit message was: " +message)
exit 1
end
end
end
# The "main" method ... when executing this file:
# Only run this if the file itself is being executed
if __FILE__ == $0
$rev_old, $rev_new, $ref = STDIN.read.split(" ")
check_message_format
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment