class Overcommit::Hook::PreCommit::AuthorEmail
Checks the format of an author’s email address.
Public Instance Methods
run()
click to toggle source
# File lib/overcommit/hook/pre_commit/author_email.rb, line 6 def run email = if ENV.key?('GIT_AUTHOR_EMAIL') ENV['GIT_AUTHOR_EMAIL'] else result = execute(%w[git config --get user.email]) result.stdout.chomp end unless email.match?(/#{config['pattern']}/) return :fail, "Author has an invalid email address: '#{email}'\n" \ 'Set your email with ' \ '`git config --global user.email your_email@example.com` ' \ 'or via the GIT_AUTHOR_EMAIL environment variable' end :pass end