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-16 21:08:46 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-16 21:08:46 +0300
commitaa0f0e992153e84e1cdec8a1c7310d5eb93a9f8f (patch)
tree4a662bc77fb43e1d1deec78cc7a95d911c0da1c5 /lib/sentry
parentd47f9d2304dbc3a23bba7fe7a5cd07218eeb41cd (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/sentry')
-rw-r--r--lib/sentry/client.rb4
-rw-r--r--lib/sentry/client/issue_link.rb27
-rw-r--r--lib/sentry/client/repo.rb38
3 files changed, 68 insertions, 1 deletions
diff --git a/lib/sentry/client.rb b/lib/sentry/client.rb
index 490f82c4678..8898960c24d 100644
--- a/lib/sentry/client.rb
+++ b/lib/sentry/client.rb
@@ -5,6 +5,8 @@ module Sentry
include Sentry::Client::Event
include Sentry::Client::Projects
include Sentry::Client::Issue
+ include Sentry::Client::Repo
+ include Sentry::Client::IssueLink
Error = Class.new(StandardError)
MissingKeysError = Class.new(StandardError)
@@ -79,7 +81,7 @@ module Sentry
end
def handle_response(response)
- unless response.code == 200
+ unless response.code.between?(200, 204)
raise_error "Sentry response status code: #{response.code}"
end
diff --git a/lib/sentry/client/issue_link.rb b/lib/sentry/client/issue_link.rb
new file mode 100644
index 00000000000..200b1a6b435
--- /dev/null
+++ b/lib/sentry/client/issue_link.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+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)
+
+ params = {
+ project: issue.project.id,
+ externalIssue: "#{issue.project.id}##{issue.iid}"
+ }
+
+ http_put(issue_link_url, params)
+ end
+
+ private
+
+ def issue_link_api_url(integration_id, sentry_issue_identifier)
+ issue_link_url = URI(url)
+ issue_link_url.path = "/api/0/groups/#{sentry_issue_identifier}/integrations/#{integration_id}/"
+
+ issue_link_url
+ end
+ end
+ end
+end
diff --git a/lib/sentry/client/repo.rb b/lib/sentry/client/repo.rb
new file mode 100644
index 00000000000..9a0ed3c7342
--- /dev/null
+++ b/lib/sentry/client/repo.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+module Sentry
+ class Client
+ module Repo
+ def repos(organization_slug)
+ repos_url = repos_api_url(organization_slug)
+
+ repos = http_get(repos_url)[:body]
+
+ handle_mapping_exceptions do
+ map_to_repos(repos)
+ end
+ end
+
+ private
+
+ def repos_api_url(organization_slug)
+ repos_url = URI(url)
+ repos_url.path = "/api/0/organizations/#{organization_slug}/repos/"
+
+ repos_url
+ end
+
+ def map_to_repos(repos)
+ repos.map(&method(:map_to_repo))
+ end
+
+ def map_to_repo(repo)
+ Gitlab::ErrorTracking::Repo.new(
+ status: repo.fetch('status'),
+ integration_id: repo.fetch('integrationId'),
+ project_id: repo.fetch('externalSlug')
+ )
+ end
+ end
+ end
+end