Sha256: 46f91d56b8656df7ff0f83025e1d4ee8a1bf4b3a6fd34d1afef6973277a6cd4b
Contents?: true
Size: 721 Bytes
Versions: 14
Compression:
Stored size: 721 Bytes
Contents
# frozen_string_literal: true module Overcommit::Hook::PreCommit # Ensures that a commit author has a name with at least first and last names. class AuthorName < Base def run name = if ENV.key?('GIT_AUTHOR_NAME') ENV['GIT_AUTHOR_NAME'] else result = execute(%w[git config --get user.name]) result.stdout.chomp end unless name.split(' ').count >= 2 return :fail, "Author must have at least first and last name, but was: #{name}.\n" \ 'Set your name with `git config --global user.name "Your Name"` ' \ 'or via the GIT_AUTHOR_NAME environment variable' end :pass end end end
Version data entries
14 entries across 14 versions & 2 rubygems