Sha256: 62953cef718fae6d9aad141025dd735bf756b932cf755686f281f21a3808218d

Contents?: true

Size: 690 Bytes

Versions: 21

Compression:

Stored size: 690 Bytes

Contents

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

21 entries across 19 versions & 2 rubygems

Version Path
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook/pre_commit/author_name.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook/pre_commit/author_name.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook/pre_commit/author_name.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.46.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.45.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.44.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.43.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.42.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.41.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.40.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.39.1 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.39.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.38.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.37.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.36.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.35.0 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.34.2 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.34.1 lib/overcommit/hook/pre_commit/author_name.rb
overcommit-0.34.0 lib/overcommit/hook/pre_commit/author_name.rb