class JiraReferenceCheckHook

This hook checks that the commit message has one or more correctly-formatted Jira ticket references.

Constants

Hook

applypatch-msg, pre-applypatch, post-applypatch prepare-commit-msg, commit-msg pre-rebase, post-checkout, post-merge, update, post-update, pre-auto-gc, post-rewrite

JIRA_TICKET_REGEXP

Public Class Methods

new(options = {}) click to toggle source
# File lib/ruby_git_hooks/jira_ref_check.rb, line 13
def initialize(options = {})
  # not using options now, but leave this here for backwards compatibility
end

Public Instance Methods

check() click to toggle source
# File lib/ruby_git_hooks/jira_ref_check.rb, line 17
def check
  if !commit_message || commit_message.length == 0
    STDERR.puts "Commit message is missing or empty!"
    return false
  end

  jira_tickets = commit_message.scan(JIRA_TICKET_REGEXP).map(&:strip)
  if jira_tickets.length == 0
    STDERR.puts "Commit message must refer to a jira ticket"
    return false
  end

  return true
end