Class: Threat::Plugins::PrTitle
- Inherits:
-
Danger::Plugin
- Object
- Danger::Plugin
- Threat::Plugins::PrTitle
- Defined in:
- lib/threat/plugins/pr_title.rb
Overview
This plugin validates that the PR title includes JIRA ticket number and a meaningful title
Usage:
Dangerfile
“‘ruby danger.import_dangerfile(gem: ’threat’)
pr_title.run! “‘
Constant Summary collapse
- JIRA_TICKET_NUMBER_FORMAT =
- KEY-123
'[A-Z]+-\d+(?:, [A-Z]+-\d+)*'
- PR_TITLE_REGEX =
- KEY-123
-
An amazing feature
/\[#{JIRA_TICKET_NUMBER_FORMAT}\] [A-Z|0-9].*\S/
Instance Method Summary collapse
Instance Method Details
#run! ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/threat/plugins/pr_title.rb', line 19 def run! # This check is available for GitHub pull requests only return unless env.request_source.instance_of?(Danger::RequestSources::GitHub) && env.pr? failure('Invalid format of PR title') unless github.pr_title.strip.match?(PR_TITLE_REGEX) end |