Class: Danger::DangerAutoLabel
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerAutoLabel
- Defined in:
- lib/auto_label/plugin.rb
Overview
No more set label to pull request manually. Example, you can set labels simply by changing the PR title.
if github.pr_title.include? “[WIP]”
auto_label.wip=(github.pr_json["number"])
end
Instance Method Summary collapse
-
#delete(name) ⇒ void
Delete label from PR.
-
#set(pr, name, color) ⇒ void
Set any labels to PR by this.
-
#wip=(pr) ⇒ void
Set WIP label to PR.
Instance Method Details
#delete(name) ⇒ void
This method returns an undefined value.
Delete label from PR.
62 63 64 |
# File 'lib/auto_label/plugin.rb', line 62 def delete(name) github.api.delete_label!(repo, name) end |
#set(pr, name, color) ⇒ void
This method returns an undefined value.
Set any labels to PR by this.
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/auto_label/plugin.rb', line 46 def set(pr, name, color) = "" if label?(name) = "Set #{name} label. (Color: #{color})" else = "Add #{name} new label. (Color: #{color})" add_label(name, color) end github.api.add_labels_to_an_issue(repo, pr, [name]) puts end |
#wip=(pr) ⇒ void
This method returns an undefined value.
Set WIP label to PR.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/auto_label/plugin.rb', line 21 def wip=(pr) label_names = [] labels.each do |label| label_names << label.name end puts("exist labels:" + label_names.join(", ")) unless wip? begin add_label("WIP") rescue Octokit::UnprocessableEntity => e puts "WIP label is already exists." puts e end end github.api.add_labels_to_an_issue(repo, pr, [wip_label]) end |