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

Version Path
overcommit-0.54.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-jeygeethanmedia-0.53.1.2 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-jeygeethanmedia-0.53.1.1 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-jeygeethanmedia-0.53.1 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.53.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.52.1 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.52.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.51.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.50.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.49.1 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.49.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.48.1 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.48.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.47.0 lib/overcommit/hook/pre_commit/author_name.rb