Sha256: 2e428eeece60fffeaeb20cf29b927861c96725c04643e86ee3d5a0af1e65affa

Contents?: true

Size: 679 Bytes

Versions: 1

Compression:

Stored size: 679 Bytes

Contents

module Danger
  class DangerCommitLint < Plugin
    class SubjectLengthCheck < CommitCheck # :nodoc:
      MESSAGE = 'Please limit commit subject line to 50 characters.'.freeze
      GIT_GENERATED_SUBJECT = /^Merge branch \'.+\' into\ /.freeze
      GITHUB_GENERATED_SUBJECT = /^Merge pull request #\d+ from\ /.freeze

      attr_reader :subject

      def self.type
        :subject_length
      end

      def initialize(message)
        @subject = message[:subject]
      end

      def fail?
        subject.length > 50 && !merge_commit?
      end

      def merge_commit?
        subject =~ /#{GIT_GENERATED_SUBJECT}|#{GITHUB_GENERATED_SUBJECT}/
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-commit_lint-0.0.7 lib/commit_lint/subject_length_check.rb