Class: Danger::DangerCommitLint::SubjectLengthCheck

Inherits:
CommitCheck
  • Object
show all
Defined in:
lib/commit_lint/subject_length_check.rb

Overview

:nodoc:

Constant Summary collapse

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CommitCheck

fail?

Constructor Details

#initialize(message) ⇒ SubjectLengthCheck

Returns a new instance of SubjectLengthCheck.



14
15
16
# File 'lib/commit_lint/subject_length_check.rb', line 14

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

Instance Attribute Details

#subjectObject (readonly)

Returns the value of attribute subject.



8
9
10
# File 'lib/commit_lint/subject_length_check.rb', line 8

def subject
  @subject
end

Class Method Details

.typeObject



10
11
12
# File 'lib/commit_lint/subject_length_check.rb', line 10

def self.type
  :subject_length
end

Instance Method Details

#fail?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/commit_lint/subject_length_check.rb', line 18

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

#merge_commit?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/commit_lint/subject_length_check.rb', line 22

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