Class: Overcommit::GitHook::TextWidth

Inherits:
HookSpecificCheck show all
Includes:
HookRegistry
Defined in:
lib/overcommit/plugins/commit_msg/text_width.rb

Instance Method Summary collapse

Methods included from HookRegistry

included

Methods inherited from HookSpecificCheck

file_type, friendly_name, #initialize, #name, required!, #skip?, skippable?, #staged, stealth!, #stealth?

Constructor Details

This class inherits a constructor from Overcommit::GitHook::HookSpecificCheck

Instance Method Details

#run_checkObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/overcommit/plugins/commit_msg/text_width.rb', line 5

def run_check
  if commit_message.first.size > 60
    return :warn, 'Please keep the subject < ~60 characters'
  end

  commit_message.each do |line|
    chomped = line.chomp
    if chomped.size > 72
      return :warn, "> 72 characters, please hard wrap: '#{chomped}'"
    end
  end

  :good
end