Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-05-30 17:59:30 +0300
committerRémy Coutable <remy@rymai.me>2017-05-30 17:59:30 +0300
commit374486fb2e1d51a059490a375d7fcd7aca4f65b8 (patch)
tree7983d00b0c0de95e52f1d6015accbfe17542695a /app
parent15a833d2d421e7e7702771417dd56443411d0927 (diff)
parentab8d54b26befb4b70988a514759c7c4d9fd7630d (diff)
Merge branch '25373-jira-links' into 'master'
Don’t create comment on JIRA if link already exists Closes #25373 See merge request !11485
Diffstat (limited to 'app')
-rw-r--r--app/models/project_services/jira_service.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb
index fe869623833..25d098b63c0 100644
--- a/app/models/project_services/jira_service.rb
+++ b/app/models/project_services/jira_service.rb
@@ -239,17 +239,26 @@ class JiraService < IssueTrackerService
return unless client_url.present?
jira_request do
- if issue.comments.build.save!(body: message)
- remote_link = issue.remotelink.build
+ remote_link = find_remote_link(issue, remote_link_props[:object][:url])
+ if remote_link
remote_link.save!(remote_link_props)
- result_message = "#{self.class.name} SUCCESS: Successfully posted to #{client_url}."
+ elsif issue.comments.build.save!(body: message)
+ new_remote_link = issue.remotelink.build
+ new_remote_link.save!(remote_link_props)
end
+ result_message = "#{self.class.name} SUCCESS: Successfully posted to #{client_url}."
Rails.logger.info(result_message)
result_message
end
end
+ def find_remote_link(issue, url)
+ links = jira_request { issue.remotelink.all }
+
+ links.find { |link| link.object["url"] == url }
+ end
+
def build_remote_link_props(url:, title:, resolved: false)
status = {
resolved: resolved