Sha256: d57b0f15c02a3a88da3bed7d870438572ac4aab8e190beacbd2a8e7890de08c0

Contents?: true

Size: 713 Bytes

Versions: 2

Compression:

Stored size: 713 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? = container[:environment]["CI"] == "true"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
git-lint-3.3.2 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-3.3.1 lib/git/lint/analyzers/commit_subject_prefix.rb