Sha256: f37c745cce591d41acdcc7a4265cd9f870f8b24a5d61cfdd3b66628e15b44703

Contents?: true

Size: 818 Bytes

Versions: 1

Compression:

Stored size: 818 Bytes

Contents

namespace :commit_msg do
  desc 'check commit msg style'
  task :check_msg do |t|
    Githook::Util.log(t.name)

    commit_msg_file = '.git/COMMIT_EDITMSG'
    commit_msg = Githook::Util.get_commit_msg(commit_msg_file)
    puts "commit-msg: #{commit_msg}"
    # can't use return in block
    # can't "exit 0" in advance, else will abort later tasks
    # but we can "exit 1" in advance
    # exit 0 if Githook::Util.expected_msg_format?(commit_msg)

    unless Githook::Util.expected_msg_format?(commit_msg)
      puts "ERROR! commit failed, commit msg doesn't match the required format"
      puts "expected msg format: #{Githook::Util::MSG_FORMAT}"
      exit 1
    end
  end
end

desc 'run all commit-msg hook tasks'
task :commit_msg do |t|
  Githook::Util.log(t.name)
  Githook::Util.run_tasks(t.name.to_sym)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git-hook-0.1.3 lib/githook/tasks/commit-msg.rake