danger-jira 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3dc20f8a0e781427f8fed365b29cb5788e99db7a
4
- data.tar.gz: eb959c279530a8aa476ec29dbc4f4d0be8163869
3
+ metadata.gz: 349f7574894426c9a762617ccdbd993a48e03158
4
+ data.tar.gz: bea55cf6f864564a26502f4ef8416005c35810ab
5
5
  SHA512:
6
- metadata.gz: f2a2e4e4b63b1eb459e10778e7b8ba2d4cd3db9c5840b6fa858ac6b54fca635d883c9d4c84e04d0b5e0a020747cd1abaefa268bfd37b9c4e67ed709de48740cf
7
- data.tar.gz: 965f18edd6800ee1ccc0723d00cd6909641f75ba9368ec3671a0b7ce0ae185a45163cb1ad96894c481d3524bb0e702d1643dbc7d47bb930ae4186e1698c34015
6
+ metadata.gz: 85fcb10b043ba8bd3411092c207ca83547f81d41335c61b8248f6ffceb0005c21f840ced3c1f10bb3cc29bdc17856cb2161005191f0ab45f148031ea54507563
7
+ data.tar.gz: 4e8f2b814fcf5a52b76dde8066e94225f3315ad9c35a2e2dd2c8e23a9d2c5523e296e637efef526e40547cf8ced22c402cdb8b55ce444da65c3877020f071c7d
data/.gitignore CHANGED
File without changes
data/.rubocop.yml CHANGED
File without changes
data/.travis.yml CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/Guardfile CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
@@ -19,12 +19,12 @@ gem 'danger-jira'
19
19
  // Dangerfile
20
20
  jira.check(
21
21
  key: ["KEY", "PM"],
22
- url: "https://myjira.atlassian.net/browse"
22
+ url: "https://myjira.atlassian.net/browse",
23
23
  fail_on_warning: true
24
24
  )
25
25
  ```
26
26
 
27
- With "KEY-123" in the PR title, Danger will comment with:
27
+ With "KEY-123" in the PR title or PR body, Danger will comment with:
28
28
 
29
29
  <table>
30
30
  <thead>
data/Rakefile CHANGED
File without changes
data/danger-jira.gemspec CHANGED
File without changes
data/lib/danger_jira.rb CHANGED
File without changes
data/lib/danger_plugin.rb CHANGED
File without changes
@@ -1,3 +1,3 @@
1
1
  module Jira
2
- VERSION = "0.3.0".freeze
2
+ VERSION = "0.4.0".freeze
3
3
  end
data/lib/jira/plugin.rb CHANGED
@@ -20,25 +20,40 @@ module Danger
20
20
  # @param [String] emoji
21
21
  # The emoji you want to display in the message.
22
22
  #
23
+ # @param [Boolean] search_title
24
+ # Option to search JIRA issues from PR title
25
+ #
26
+ # @param [Boolean] search_commits
27
+ # Option to search JIRA issues from commit messages
28
+ #
23
29
  # @param [Boolean] fail_on_warning
24
- # Option to fail danger if no JIRA issue found in PR title
30
+ # Option to fail danger if no JIRA issue found
31
+ #
32
+ # @param [Boolean] report_missing
33
+ # Option to report if no JIRA issue was found
25
34
  #
26
35
  # @return [void]
27
36
  #
28
- def check(key: nil, url: nil, emoji: ":link:", fail_on_warning: false)
37
+ def check(key: nil, url: nil, emoji: ":link:", search_title: true, search_commits: false, fail_on_warning: false, report_missing: true)
29
38
  throw Error("'key' missing - must supply JIRA issue key") if key.nil?
30
39
  throw Error("'url' missing - must supply JIRA installation URL") if url.nil?
31
40
 
32
41
  # Support multiple JIRA projects
33
42
  keys = key.kind_of?(Array) ? key.join("|") : key
34
- jira_key_regex_string = "((#{keys})-[0-9]+)"
43
+ jira_key_regex_string = "((?:#{keys})-[0-9]+)"
35
44
  regexp = Regexp.new(/#{jira_key_regex_string}/)
36
45
 
37
46
  jira_issues = []
38
- github.pr_title.gsub(regexp) do |match|
39
- jira_issues << match
47
+
48
+ if search_title
49
+ jira_issues << github.pr_title.scan(regexp)
50
+ end
51
+ if search_commits
52
+ jira_issues << git.commits.map { |commit| commit.message.scan(regexp) }.compact
40
53
  end
41
54
 
55
+ jira_issues.flatten.uniq
56
+
42
57
  if jira_issues.empty?
43
58
  github.pr_body.gsub(regexp) do |match|
44
59
  jira_issues << match
@@ -48,8 +63,8 @@ module Danger
48
63
  if !jira_issues.empty?
49
64
  jira_urls = jira_issues.map { |issue| link(href: ensure_url_ends_with_slash(url), issue: issue) }.join(", ")
50
65
  message("#{emoji} #{jira_urls}")
51
- else
52
- msg = "This PR does not contain a JIRA issue key in the PR title (e.g. KEY-123)"
66
+ elsif report_missing
67
+ msg = "This PR does not contain any JIRA issue keys in the PR title or commit messages (e.g. KEY-123)"
53
68
  if fail_on_warning
54
69
  fail(msg)
55
70
  else
data/spec/jira_spec.rb CHANGED
File without changes
data/spec/spec_helper.rb CHANGED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-jira
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - RestlessThinker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-13 00:00:00.000000000 Z
11
+ date: 2018-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api