Sha256: 42b089aa46aabf8b8c24c4a04ba99a16cfb16aa5cb81faa84d463e7d3afff13c

Contents?: true

Size: 930 Bytes

Versions: 6

Compression:

Stored size: 930 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
          configuration.commits_subject_prefix_includes
                       .map { |prefix| "#{prefix}#{delimiter}" }
                       .then { |list| Kit::FilterList.new list }
        end

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

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

        def delimiter = configuration.commits_subject_prefix_delimiter
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
git-lint-6.2.1 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-6.2.0 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-6.1.0 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-6.0.2 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-6.0.1 lib/git/lint/analyzers/commit_subject_prefix.rb
git-lint-6.0.0 lib/git/lint/analyzers/commit_subject_prefix.rb