lib/jira/plugin.rb in danger-jira-0.5.1 vs lib/jira/plugin.rb in danger-jira-0.6.0
- old
+ new
@@ -62,20 +62,25 @@
end
end
private
+ def vcs_host
+ return gitlab if defined? @dangerfile.gitlab
+ return github
+ end
+
def find_jira_issues(key: nil, search_title: true, search_commits: false)
# Support multiple JIRA projects
keys = key.kind_of?(Array) ? key.join("|") : key
jira_key_regex_string = "((?:#{keys})-[0-9]+)"
regexp = Regexp.new(/#{jira_key_regex_string}/)
jira_issues = []
if search_title
- github.pr_title.gsub(regexp) do |match|
+ vcs_host.pr_title.gsub(regexp) do |match|
jira_issues << match
end
end
if search_commits
@@ -85,11 +90,11 @@
end
end
end
if jira_issues.empty?
- github.pr_body.gsub(regexp) do |match|
+ vcs_host.pr_body.gsub(regexp) do |match|
jira_issues << match
end
end
return jira_issues.uniq
end
@@ -97,15 +102,15 @@
def should_skip_jira?(search_title: true)
# Consider first occurrence of 'no-jira'
regexp = Regexp.new("no-jira", true)
if search_title
- github.pr_title.gsub(regexp) do |match|
+ vcs_host.pr_title.gsub(regexp) do |match|
return true unless match.empty?
end
end
- github.pr_body.gsub(regexp) do |match|
+ vcs_host.pr_body.gsub(regexp) do |match|
return true unless match.empty?
end
return false
end