module Causes::GitHook
  class RussianNovel < HookSpecificCheck
    include HookRegistry

    RUSSIAN_NOVEL_LENGTH = 30
    def run_check
      count = 0
      commit_message.find do |line|
        count += 1 unless comment?(line)
        diff_started?(line)
      end

      if count > RUSSIAN_NOVEL_LENGTH
        return :warn, 'You seem to have authored a Russian novel; congratulations!'
      end

      :good
    end

  private

    def diff_started?(line)
      line =~ /^diff --git /
    end

    def comment?(line)
      line =~ /^#/
    end
  end
end

Add "Russian Novel" easter egg
Add "Russian Novel" easter egg

To surprise and delight.

Change-Id: I49350c9d9a974cfc9f786d0d0c23937812ded029
Reviewed-on: https://gerrit.causes.com/22229
Tested-by: Greg Hurrell <79e2475f81a6317276bf7cbb3958b20d289b78df@causes.com>
Reviewed-by: Shane da Silva <6f6e68d1df92f30cb4b3ce35260ddf94a402f33d@causes.com>
