Sha256: 9ee5ba073f7926822ef1272e29ac729c99444656743cc55bd108795a91879823

Contents?: true

Size: 829 Bytes

Versions: 11

Compression:

Stored size: 829 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      # Analyzes commit subject uses standard prefix.
      class CommitSubjectPrefix < Abstract
        def valid?
          return true if locally_prefixed?
          return true if filter_list.empty?

          commit.subject.match?(/\A#{Regexp.union filter_list.to_regexp}/)
        end

        def issue
          return {} if valid?

          {hint: %(Use: #{filter_list.to_hint}.)}
        end

        protected

        def load_filter_list
          settings.includes
                  .map { |prefix| "#{prefix}#{settings.delimiter}" }
                  .then { |list| Kit::FilterList.new list }
        end

        def locally_prefixed? = !ci? && commit.prefix?

        def ci? = environment["CI"] == "true"
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
git-lint-5.3.0 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-5.2.0 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-5.1.2 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-5.1.1 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-5.1.0 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-5.0.0 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-4.6.0 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-4.5.0 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-4.4.0 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-4.3.0 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-4.2.0 lib/git/lint/analyzers/commit_subject_prefix.rb