Class: Danger::DangerMailmap
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerMailmap
- Defined in:
- lib/danger_plugin.rb
Overview
A Danger plugin to check if .mailmap has a canonical name of author and committer.
Instance Attribute Summary collapse
-
#allowed_patterns ⇒ Array<String, Regexp>
Regular expression patterns of email where ‘danger-mailmap` does not warn like allow-list.
-
#show_suggestion ⇒ Boolean
If ‘true`, `danger-mailmap` will add suggestion comments to a pull request (`true` by default).
Instance Method Summary collapse
-
#check(path = nil) ⇒ void
Check whether if an author of each commits has proper email.
-
#initialize(*args) ⇒ DangerMailmap
constructor
A new instance of DangerMailmap.
Constructor Details
#initialize(*args) ⇒ DangerMailmap
Returns a new instance of DangerMailmap.
36 37 38 39 |
# File 'lib/danger_plugin.rb', line 36 def initialize(*args) super(*args) self.show_suggestion = true end |
Instance Attribute Details
#allowed_patterns ⇒ Array<String, Regexp>
Regular expression patterns of email where ‘danger-mailmap` does not warn like allow-list. If a string is set, it is considered as fixed pattern.
30 31 32 |
# File 'lib/danger_plugin.rb', line 30 def allowed_patterns @allowed_patterns end |
#show_suggestion ⇒ Boolean
If ‘true`, `danger-mailmap` will add suggestion comments to a pull request (`true` by default).
34 35 36 |
# File 'lib/danger_plugin.rb', line 34 def show_suggestion @show_suggestion end |
Instance Method Details
#check(path = nil) ⇒ void
This method returns an undefined value.
Check whether if an author of each commits has proper email.
45 46 47 48 49 50 51 52 53 |
# File 'lib/danger_plugin.rb', line 45 def check(path = nil) path = path ? File.(path) : File.join(git_working_dir, '.mailmap') mailmap = Mailmap::Map.load(path) commits_by_emails = commits_by_unknown_emails(mailmap) return if commits_by_emails.empty? commits_by_emails.each { |email, commits| warn(format_warning(path, email, commits)) } markdown(suggestion(path, commits_by_emails.keys)) if show_suggestion end |