summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-12 15:08:41 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-12 15:08:41 +0000
commit27859ed5eaeae234162b7cce7fd8bd351b5f9369 (patch)
tree5a62db348c3fd73516df87262c78e3546d4ec770 /lib
parent784fae4b9d7e92350075df2a43d06893080ed1e6 (diff)
downloadgitlab-ce-27859ed5eaeae234162b7cce7fd8bd351b5f9369.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/danger/changelog.rb40
-rw-r--r--lib/sentry/client.rb39
-rw-r--r--lib/sentry/client/projects.rb46
3 files changed, 88 insertions, 37 deletions
diff --git a/lib/gitlab/danger/changelog.rb b/lib/gitlab/danger/changelog.rb
new file mode 100644
index 00000000000..b53516081be
--- /dev/null
+++ b/lib/gitlab/danger/changelog.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Danger
+ module Changelog
+ NO_CHANGELOG_LABELS = %w[backstage ci-build meta].freeze
+ NO_CHANGELOG_CATEGORIES = %i[docs none].freeze
+
+ def needed?
+ categories_need_changelog? && (gitlab.mr_labels & NO_CHANGELOG_LABELS).empty?
+ end
+
+ def found
+ git.added_files.find { |path| path =~ %r{\A(ee/)?(changelogs/unreleased)(-ee)?/} }
+ end
+
+ def presented_no_changelog_labels
+ NO_CHANGELOG_LABELS.map { |label| "~#{label}" }.join(', ')
+ end
+
+ def sanitized_mr_title
+ gitlab.mr_json["title"].gsub(/^WIP: */, '').gsub(/`/, '\\\`')
+ end
+
+ def ee_changelog?(changelog_path)
+ changelog_path =~ /unreleased-ee/
+ end
+
+ def ce_port_changelog?(changelog_path)
+ helper.ee? && !ee_changelog?(changelog_path)
+ end
+
+ private
+
+ def categories_need_changelog?
+ (helper.changes_by_category.keys - NO_CHANGELOG_CATEGORIES).any?
+ end
+ end
+ end
+end
diff --git a/lib/sentry/client.rb b/lib/sentry/client.rb
index 6cbee830b17..47b497accc1 100644
--- a/lib/sentry/client.rb
+++ b/lib/sentry/client.rb
@@ -2,6 +2,8 @@
module Sentry
class Client
+ include Sentry::Client::Projects
+
Error = Class.new(StandardError)
MissingKeysError = Class.new(StandardError)
ResponseInvalidSizeError = Class.new(StandardError)
@@ -49,14 +51,6 @@ module Sentry
end
end
- def list_projects
- projects = get_projects
-
- handle_mapping_exceptions do
- map_to_projects(projects)
- end
- end
-
private
def validate_size(issues)
@@ -121,10 +115,6 @@ module Sentry
http_get(issue_latest_event_api_url(issue_id))[:body]
end
- def get_projects
- http_get(projects_api_url)[:body]
- end
-
def handle_request_exceptions
yield
rescue Gitlab::HTTP::Error => e
@@ -155,13 +145,6 @@ module Sentry
raise Client::Error, message
end
- def projects_api_url
- projects_url = URI(@url)
- projects_url.path = '/api/0/projects/'
-
- projects_url
- end
-
def issue_api_url(issue_id)
issue_url = URI(@url)
issue_url.path = "/api/0/issues/#{issue_id}/"
@@ -187,10 +170,6 @@ module Sentry
issues.map(&method(:map_to_error))
end
- def map_to_projects(projects)
- projects.map(&method(:map_to_project))
- end
-
def issue_url(id)
issues_url = @url + "/issues/#{id}"
@@ -289,19 +268,5 @@ module Sentry
project_slug: issue.dig('project', 'slug')
)
end
-
- def map_to_project(project)
- organization = project.fetch('organization')
-
- Gitlab::ErrorTracking::Project.new(
- id: project.fetch('id', nil),
- name: project.fetch('name'),
- slug: project.fetch('slug'),
- status: project.dig('status'),
- organization_name: organization.fetch('name'),
- organization_id: organization.fetch('id', nil),
- organization_slug: organization.fetch('slug')
- )
- end
end
end
diff --git a/lib/sentry/client/projects.rb b/lib/sentry/client/projects.rb
new file mode 100644
index 00000000000..68f8fe0f9c9
--- /dev/null
+++ b/lib/sentry/client/projects.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+module Sentry
+ class Client
+ module Projects
+ def projects
+ projects = get_projects
+
+ handle_mapping_exceptions do
+ map_to_projects(projects)
+ end
+ end
+
+ private
+
+ def get_projects
+ http_get(projects_api_url)[:body]
+ end
+
+ def projects_api_url
+ projects_url = URI(url)
+ projects_url.path = '/api/0/projects/'
+
+ projects_url
+ end
+
+ def map_to_projects(projects)
+ projects.map(&method(:map_to_project))
+ end
+
+ def map_to_project(project)
+ organization = project.fetch('organization')
+
+ Gitlab::ErrorTracking::Project.new(
+ id: project.fetch('id', nil),
+ name: project.fetch('name'),
+ slug: project.fetch('slug'),
+ status: project.dig('status'),
+ organization_name: organization.fetch('name'),
+ organization_id: organization.fetch('id', nil),
+ organization_slug: organization.fetch('slug')
+ )
+ end
+ end
+ end
+end