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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-22 18:08:48 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-22 18:08:48 +0300
commit180cd023a11c0eb413ad0de124d9758ea25672bd (patch)
tree63d77be00a22dc637daa0b6d5b644e230f5f4890 /lib/sentry/client
parentbe3e24ea3c9f497efde85900df298ce9bc42fce8 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/sentry/client')
-rw-r--r--lib/sentry/client/issue_link.rb35
1 files changed, 30 insertions, 5 deletions
diff --git a/lib/sentry/client/issue_link.rb b/lib/sentry/client/issue_link.rb
index 200b1a6b435..91498c19f8b 100644
--- a/lib/sentry/client/issue_link.rb
+++ b/lib/sentry/client/issue_link.rb
@@ -3,8 +3,22 @@
module Sentry
class Client
module IssueLink
- def create_issue_link(integration_id, sentry_issue_identifier, issue)
- issue_link_url = issue_link_api_url(integration_id, sentry_issue_identifier)
+ # Creates a link in Sentry corresponding to the provided
+ # Sentry issue and GitLab issue
+ # @param integration_id [Integer, nil] Representing a global
+ # GitLab integration in Sentry. Nil for plugins.
+ # @param sentry_issue_id [Integer] Id for an issue from Sentry
+ # @param issue [Issue] Issue for which the link should be created
+ def create_issue_link(integration_id, sentry_issue_id, issue)
+ return create_plugin_link(sentry_issue_id, issue) unless integration_id
+
+ create_global_integration_link(integration_id, sentry_issue_id, issue)
+ end
+
+ private
+
+ def create_global_integration_link(integration_id, sentry_issue_id, issue)
+ issue_link_url = global_integration_link_api_url(integration_id, sentry_issue_id)
params = {
project: issue.project.id,
@@ -14,11 +28,22 @@ module Sentry
http_put(issue_link_url, params)
end
- private
+ def global_integration_link_api_url(integration_id, sentry_issue_id)
+ issue_link_url = URI(url)
+ issue_link_url.path = "/api/0/groups/#{sentry_issue_id}/integrations/#{integration_id}/"
+
+ issue_link_url
+ end
+
+ def create_plugin_link(sentry_issue_id, issue)
+ issue_link_url = plugin_link_api_url(sentry_issue_id)
+
+ http_post(issue_link_url, issue_id: issue.iid)
+ end
- def issue_link_api_url(integration_id, sentry_issue_identifier)
+ def plugin_link_api_url(sentry_issue_id)
issue_link_url = URI(url)
- issue_link_url.path = "/api/0/groups/#{sentry_issue_identifier}/integrations/#{integration_id}/"
+ issue_link_url.path = "/api/0/issues/#{sentry_issue_id}/plugins/gitlab/link/"
issue_link_url
end