summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-23 15:09:36 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-23 15:09:36 +0000
commit074d013e1eb3f6e0c27f96a3be8b9361254c8a98 (patch)
treef185c474ddc8624a4793c84b0b1f4cc07349694b /lib
parent8f9beefac3774b30e911fb00a68f4c7a5244cf27 (diff)
downloadgitlab-ce-074d013e1eb3f6e0c27f96a3be8b9361254c8a98.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/api/entities/commit_with_link.rb53
-rw-r--r--lib/api/entities/user_path.rb14
-rw-r--r--lib/api/merge_requests.rb2
-rw-r--r--lib/gitlab/danger/changelog.rb10
-rw-r--r--lib/gitlab/danger/helper.rb4
-rw-r--r--lib/gitlab/file_detector.rb2
-rw-r--r--lib/gitlab/metrics/dashboard/finder.rb2
-rw-r--r--lib/gitlab/metrics/dashboard/service_selector.rb2
-rw-r--r--lib/gitlab/sidekiq_middleware/duplicate_jobs.rb14
-rw-r--r--lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb2
10 files changed, 91 insertions, 14 deletions
diff --git a/lib/api/entities/commit_with_link.rb b/lib/api/entities/commit_with_link.rb
new file mode 100644
index 00000000000..31a9efed9bc
--- /dev/null
+++ b/lib/api/entities/commit_with_link.rb
@@ -0,0 +1,53 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ class CommitWithLink < Commit
+ include MarkupHelper
+ include RequestAwareEntity
+
+ expose :author, using: Entities::UserPath
+
+ expose :author_gravatar_url do |commit|
+ GravatarService.new.execute(commit.author_email)
+ end
+
+ expose :commit_url do |commit, options|
+ project_commit_url(request.project, commit, params: options.fetch(:commit_url_params, {}))
+ end
+
+ expose :commit_path do |commit, options|
+ project_commit_path(request.project, commit, params: options.fetch(:commit_url_params, {}))
+ end
+
+ expose :description_html, if: { type: :full } do |commit|
+ markdown_field(commit, :description)
+ end
+
+ expose :title_html, if: { type: :full } do |commit|
+ markdown_field(commit, :title)
+ end
+
+ expose :signature_html, if: { type: :full } do |commit|
+ render('projects/commit/_signature', signature: commit.signature) if commit.has_signature?
+ end
+
+ expose :pipeline_status_path, if: { type: :full } do |commit, options|
+ pipeline_ref = options[:pipeline_ref]
+ pipeline_project = options[:pipeline_project] || commit.project
+ next unless pipeline_ref && pipeline_project
+
+ pipeline = commit.latest_pipeline_for_project(pipeline_ref, pipeline_project)
+ next unless pipeline&.status
+
+ pipelines_project_commit_path(pipeline_project, commit.id, ref: pipeline_ref)
+ end
+
+ def render(*args)
+ return unless request.respond_to?(:render) && request.render.respond_to?(:call)
+
+ request.render.call(*args)
+ end
+ end
+ end
+end
diff --git a/lib/api/entities/user_path.rb b/lib/api/entities/user_path.rb
new file mode 100644
index 00000000000..7d922b39654
--- /dev/null
+++ b/lib/api/entities/user_path.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ class UserPath < UserBasic
+ include RequestAwareEntity
+ include UserStatusTooltip
+
+ expose :path do |user|
+ user_path(user)
+ end
+ end
+ end
+end
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb
index 2b1bcc855d2..4d9f035e2cd 100644
--- a/lib/api/merge_requests.rb
+++ b/lib/api/merge_requests.rb
@@ -306,7 +306,7 @@ module API
context_commits =
paginate(merge_request.merge_request_context_commits).map(&:to_commit)
- present context_commits, with: Entities::Commit
+ present context_commits, with: Entities::CommitWithLink, type: :full, request: merge_request
end
params do
diff --git a/lib/gitlab/danger/changelog.rb b/lib/gitlab/danger/changelog.rb
index b53516081be..d64177f9565 100644
--- a/lib/gitlab/danger/changelog.rb
+++ b/lib/gitlab/danger/changelog.rb
@@ -11,7 +11,7 @@ module Gitlab
end
def found
- git.added_files.find { |path| path =~ %r{\A(ee/)?(changelogs/unreleased)(-ee)?/} }
+ @found ||= git.added_files.find { |path| path =~ %r{\A(ee/)?(changelogs/unreleased)(-ee)?/} }
end
def presented_no_changelog_labels
@@ -22,12 +22,8 @@ module Gitlab
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)
+ def ee_changelog?
+ found.start_with?('ee/')
end
private
diff --git a/lib/gitlab/danger/helper.rb b/lib/gitlab/danger/helper.rb
index 77a84634815..6bb46b1730f 100644
--- a/lib/gitlab/danger/helper.rb
+++ b/lib/gitlab/danger/helper.rb
@@ -34,6 +34,10 @@ module Gitlab
.sort
end
+ def all_ee_changes
+ all_changed_files.grep(%r{\Aee/})
+ end
+
def ee?
# Support former project name for `dev` and support local Danger run
%w[gitlab gitlab-ee].include?(ENV['CI_PROJECT_NAME']) || Dir.exist?('../../ee')
diff --git a/lib/gitlab/file_detector.rb b/lib/gitlab/file_detector.rb
index 305fbeecce1..a9e9261cd3c 100644
--- a/lib/gitlab/file_detector.rb
+++ b/lib/gitlab/file_detector.rb
@@ -40,7 +40,7 @@ module Gitlab
yarn_lock: 'yarn.lock',
# OpenAPI Specification files
- openapi: %r{.*(openapi|swagger).*\.(yaml|yml|json)\z}i
+ openapi: %r{[^/]*(openapi|swagger)[^/]*\.(yaml|yml|json)\z}i
}.freeze
# Returns an Array of file types based on the given paths.
diff --git a/lib/gitlab/metrics/dashboard/finder.rb b/lib/gitlab/metrics/dashboard/finder.rb
index 990fd57bf41..d80985e0a0e 100644
--- a/lib/gitlab/metrics/dashboard/finder.rb
+++ b/lib/gitlab/metrics/dashboard/finder.rb
@@ -78,7 +78,7 @@ module Gitlab
end
def project_service
- ::Metrics::Dashboard::ProjectDashboardService
+ ::Metrics::Dashboard::CustomDashboardService
end
def self_monitoring_service
diff --git a/lib/gitlab/metrics/dashboard/service_selector.rb b/lib/gitlab/metrics/dashboard/service_selector.rb
index 993e508cbc6..281538de502 100644
--- a/lib/gitlab/metrics/dashboard/service_selector.rb
+++ b/lib/gitlab/metrics/dashboard/service_selector.rb
@@ -20,7 +20,7 @@ module Gitlab
::Metrics::Dashboard::SystemDashboardService,
::Metrics::Dashboard::PodDashboardService,
::Metrics::Dashboard::SelfMonitoringDashboardService,
- ::Metrics::Dashboard::ProjectDashboardService
+ ::Metrics::Dashboard::CustomDashboardService
].freeze
# Returns a class which inherits from the BaseService
diff --git a/lib/gitlab/sidekiq_middleware/duplicate_jobs.rb b/lib/gitlab/sidekiq_middleware/duplicate_jobs.rb
index 23222430902..f0e26f99c2c 100644
--- a/lib/gitlab/sidekiq_middleware/duplicate_jobs.rb
+++ b/lib/gitlab/sidekiq_middleware/duplicate_jobs.rb
@@ -5,8 +5,18 @@ require 'digest'
module Gitlab
module SidekiqMiddleware
module DuplicateJobs
- def self.drop_duplicates?
- Feature.enabled?(:drop_duplicate_sidekiq_jobs)
+ DROPPABLE_QUEUES = Set.new([
+ Namespaces::RootStatisticsWorker.queue
+ ]).freeze
+
+ def self.drop_duplicates?(queue_name)
+ Feature.enabled?(:drop_duplicate_sidekiq_jobs) ||
+ drop_duplicates_for_queue?(queue_name)
+ end
+
+ private_class_method def self.drop_duplicates_for_queue?(queue_name)
+ DROPPABLE_QUEUES.include?(queue_name) &&
+ Feature.enabled?(:drop_duplicate_sidekiq_jobs_for_queue)
end
end
end
diff --git a/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb b/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb
index c6fb50b4610..a9007039334 100644
--- a/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb
+++ b/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb
@@ -67,7 +67,7 @@ module Gitlab
end
def droppable?
- idempotent? && duplicate? && DuplicateJobs.drop_duplicates?
+ idempotent? && duplicate? && DuplicateJobs.drop_duplicates?(queue_name)
end
private