Sha256: 16c67450bb507fc02e4fb3783bec2a637d196510f4b2666799ba0a7c9e84763d

Contents?: true

Size: 701 Bytes

Versions: 3

Compression:

Stored size: 701 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 = Kit::FilterList.new(settings.includes)

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git-lint-4.1.0 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-4.0.1 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-4.0.0 lib/git/lint/analyzers/commit_subject_prefix.rb