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:
authorGitLab Bot <gitlab-bot@gitlab.com>2024-01-08 12:12:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2024-01-08 12:12:05 +0300
commitd59bc6c73d927d63d04f86f8b1d2e471787d48d1 (patch)
tree205daf86ac4049e30479a521a24f3242ff326a7a /app
parent80abbcbeaf4b0c47a8fe6201bd5e2d9c8af6e272 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/controllers/concerns/integrations/params.rb3
-rw-r--r--app/finders/projects_finder.rb2
-rw-r--r--app/models/ci/build.rb8
-rw-r--r--app/models/commit_status.rb2
-rw-r--r--app/models/concerns/routable.rb15
-rw-r--r--app/models/integration.rb4
-rw-r--r--app/models/integrations/diffblue_cover.rb126
-rw-r--r--app/models/project.rb1
-rw-r--r--app/models/time_tracking/timelog_category.rb2
-rw-r--r--app/models/timelog.rb1
-rw-r--r--app/services/clusters/agents/authorizations/user_access/refresh_service.rb4
11 files changed, 156 insertions, 12 deletions
diff --git a/app/controllers/concerns/integrations/params.rb b/app/controllers/concerns/integrations/params.rb
index e344e0dcd8c..d71ab98c3fd 100644
--- a/app/controllers/concerns/integrations/params.rb
+++ b/app/controllers/concerns/integrations/params.rb
@@ -38,6 +38,9 @@ module Integrations
:default_irc_uri,
:device,
:disable_diffs,
+ :diffblue_access_token_name,
+ :diffblue_access_token_secret,
+ :diffblue_license_key,
:drone_url,
:enable_ssl_verification,
:external_wiki_url,
diff --git a/app/finders/projects_finder.rb b/app/finders/projects_finder.rb
index 57eea577419..cd919c88f99 100644
--- a/app/finders/projects_finder.rb
+++ b/app/finders/projects_finder.rb
@@ -173,7 +173,7 @@ class ProjectsFinder < UnionFinder
# rubocop: enable CodeReuse/ActiveRecord
def by_full_paths(items)
- params[:full_paths].present? ? items.where_full_path_in(params[:full_paths], use_includes: false) : items
+ params[:full_paths].present? ? items.where_full_path_in(params[:full_paths], preload_routes: false) : items
end
def union(items)
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 66e9e20f3dc..ffc9106bc29 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -100,6 +100,7 @@ module Ci
delegate :harbor_integration, to: :project
delegate :apple_app_store_integration, to: :project
delegate :google_play_integration, to: :project
+ delegate :diffblue_cover_integration, to: :project
delegate :trigger_short_token, to: :trigger_request, allow_nil: true
delegate :ensure_persistent_ref, to: :pipeline
delegate :enable_debug_trace!, to: :metadata
@@ -522,6 +523,7 @@ module Ci
.concat(harbor_variables)
.concat(apple_app_store_variables)
.concat(google_play_variables)
+ .concat(diffblue_cover_variables)
end
end
@@ -574,6 +576,12 @@ module Ci
Gitlab::Ci::Variables::Collection.new(google_play_integration.ci_variables(protected_ref: pipeline.protected_ref?))
end
+ def diffblue_cover_variables
+ return [] unless diffblue_cover_integration.try(:activated?)
+
+ Gitlab::Ci::Variables::Collection.new(diffblue_cover_integration.ci_variables)
+ end
+
def features
{
trace_sections: true,
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index f1aeb7e528f..3a9b1465682 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -86,7 +86,7 @@ class CommitStatus < Ci::ApplicationRecord
scope :for_project_paths, -> (paths) do
# Pluck is used to split this query. Splitting the query is required for database decomposition for `ci_*` tables.
# https://docs.gitlab.com/ee/development/database/transaction_guidelines.html#database-decomposition-and-sharding
- project_ids = Project.where_full_path_in(Array(paths), use_includes: false).pluck(:id)
+ project_ids = Project.where_full_path_in(Array(paths), preload_routes: false).pluck(:id)
for_project(project_ids)
end
diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb
index 0348c774b2d..43874d0211c 100644
--- a/app/models/concerns/routable.rb
+++ b/app/models/concerns/routable.rb
@@ -87,21 +87,24 @@ module Routable
# Klass.where_full_path_in(%w{gitlab-org/gitlab-foss gitlab-org/gitlab})
#
# Returns an ActiveRecord::Relation.
- def where_full_path_in(paths, use_includes: true)
+ def where_full_path_in(paths, preload_routes: true)
return none if paths.empty?
- wheres = paths.map do |path|
+ path_condition = paths.map do |path|
"(LOWER(routes.path) = LOWER(#{connection.quote(path)}))"
- end
+ end.join(' OR ')
route_scope = all
source_type_condition = { source_type: route_scope.klass.base_class }
- routes_matching_condition = Route.where(source_type_condition).where(wheres.join(' OR '))
+ routes_matching_condition = Route
+ .where(source_type_condition)
+ .where(path_condition)
- result = route_scope.where(id: routes_matching_condition.pluck(:source_id))
+ source_ids = routes_matching_condition.pluck(:source_id)
+ result = route_scope.where(id: source_ids)
- if use_includes
+ if preload_routes
result.preload(:route)
else
result
diff --git a/app/models/integration.rb b/app/models/integration.rb
index cd7350b2549..8ebf24b1663 100644
--- a/app/models/integration.rb
+++ b/app/models/integration.rb
@@ -19,8 +19,8 @@ class Integration < ApplicationRecord
self.inheritance_column = :type_new
INTEGRATION_NAMES = %w[
- asana assembla bamboo bugzilla buildkite campfire clickup confluence custom_issue_tracker datadog discord
- drone_ci emails_on_push ewm external_wiki hangouts_chat harbor irker jira
+ asana assembla bamboo bugzilla buildkite campfire clickup confluence custom_issue_tracker
+ datadog diffblue_cover discord drone_ci emails_on_push ewm external_wiki hangouts_chat harbor irker jira
mattermost mattermost_slash_commands microsoft_teams packagist pipelines_email
pivotaltracker prometheus pumble pushover redmine slack slack_slash_commands squash_tm teamcity telegram
unify_circuit webex_teams youtrack zentao
diff --git a/app/models/integrations/diffblue_cover.rb b/app/models/integrations/diffblue_cover.rb
new file mode 100644
index 00000000000..888aa9a5ffd
--- /dev/null
+++ b/app/models/integrations/diffblue_cover.rb
@@ -0,0 +1,126 @@
+# frozen_string_literal: true
+
+module Integrations
+ class DiffblueCover < Integration
+ field :diffblue_license_key,
+ section: SECTION_TYPE_CONNECTION,
+ type: :password,
+ title: -> { s_('DiffblueCover|License key') },
+ description: -> { s_('DiffblueCover|Diffblue Cover license key') },
+ non_empty_password_title: -> { s_('DiffblueCover|License key') },
+ non_empty_password_help: -> {
+ s_(
+ 'DiffblueCover|Leave blank to use your current license key.'
+ )
+ },
+ exposes_secrets: true,
+ required: true,
+ is_secret: true,
+ placeholder: 'XXXX-XXXX-XXXX-XXXX',
+ help: -> {
+ format(
+ s_(
+ 'DiffblueCover|Enter your Diffblue Cover license key or ' \
+ 'visit %{diffblue_link} to obtain a free trial license.'
+ ),
+ diffblue_link: diffblue_link
+ )
+ }
+
+ field :diffblue_access_token_name,
+ section: SECTION_TYPE_CONFIGURATION,
+ title: -> { s_('DiffblueCover|Name') },
+ description: -> { s_('DiffblueCover|Access token name used by Diffblue Cover in pipelines') },
+ required: true,
+ placeholder: -> { s_('DiffblueCover|My token name') }
+
+ field :diffblue_access_token_secret,
+ section: SECTION_TYPE_CONFIGURATION,
+ type: :password,
+ title: -> { s_('DiffblueCover|Secret') },
+ description: -> { s_('DiffblueCover|Access token secret used by Diffblue Cover in pipelines') },
+ non_empty_password_title: -> { s_('DiffblueCover|Secret') },
+ non_empty_password_help: -> { s_('DiffblueCover|Leave blank to use your current secret value.') },
+ required: true,
+ is_secret: true,
+ placeholder: 'glpat-XXXXXXXXXXXXXXXXXXXX' # gitleaks:allow
+
+ with_options if: :activated? do
+ validates :diffblue_license_key, presence: true
+ validates :diffblue_access_token_name, presence: true
+ validates :diffblue_access_token_secret, presence: true
+ end
+
+ def self.title
+ 'Diffblue Cover'
+ end
+
+ def self.description
+ s_('DiffblueCover|Automatically write comprehensive, human-like Java unit tests.')
+ end
+
+ def self.to_param
+ 'diffblue_cover'
+ end
+
+ def self.help
+ s_('DiffblueCover|Automatically write comprehensive, human-like Java unit tests.')
+ end
+
+ def avatar_url
+ ActionController::Base.helpers.image_path('illustrations/third-party-logos/integrations-logos/diffblue.svg')
+ end
+
+ def self.supported_events
+ []
+ end
+
+ def sections
+ [
+ {
+ type: SECTION_TYPE_CONNECTION,
+ title: s_('DiffblueCover|Integration details'),
+ description:
+ s_(
+ 'DiffblueCover|Diffblue Cover is a reinforcement learning AI platform that automatically ' \
+ 'writes comprehensive, human-like Java unit tests. Integrate the power of Diffblue ' \
+ 'Cover into your CI/CD workflow for fully autonomous operation.'
+ )
+ },
+ {
+ type: SECTION_TYPE_CONFIGURATION,
+ title: s_('DiffblueCover|Access token'),
+ description:
+ 'A GitLab access token is required in allow Diffblue Cover to access your project. ' \
+ 'Use a GitLab access token with a <code>Developer</code> role, plus ' \
+ '<code>api</code> and <code>write_repository</code> scopes.'
+ }
+ ]
+ end
+
+ def execute(_data) end
+
+ def ci_variables
+ return [] unless activated?
+
+ [
+ { key: 'DIFFBLUE_LICENSE_KEY', value: diffblue_license_key, public: false, masked: true },
+ { key: 'DIFFBLUE_ACCESS_TOKEN_NAME', value: diffblue_access_token_name, public: false, masked: true },
+ { key: 'DIFFBLUE_ACCESS_TOKEN', value: diffblue_access_token_secret, public: false, masked: true }
+ ]
+ end
+
+ def testable?
+ false
+ end
+
+ def self.diffblue_link
+ ActionController::Base.helpers.link_to(
+ s_('DiffblueCover|Try Diffblue Cover'),
+ 'https://www.diffblue.com/try-cover/gitlab/',
+ target: '_blank',
+ rel: 'noopener noreferrer'
+ )
+ end
+ end
+end
diff --git a/app/models/project.rb b/app/models/project.rb
index 35a664f080a..ea5eff7e6a6 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -208,6 +208,7 @@ class Project < ApplicationRecord
has_one :custom_issue_tracker_integration, class_name: 'Integrations::CustomIssueTracker'
has_one :datadog_integration, class_name: 'Integrations::Datadog'
has_one :container_registry_data_repair_detail, class_name: 'ContainerRegistry::DataRepairDetail'
+ has_one :diffblue_cover_integration, class_name: 'Integrations::DiffblueCover'
has_one :discord_integration, class_name: 'Integrations::Discord'
has_one :drone_ci_integration, class_name: 'Integrations::DroneCi'
has_one :emails_on_push_integration, class_name: 'Integrations::EmailsOnPush'
diff --git a/app/models/time_tracking/timelog_category.rb b/app/models/time_tracking/timelog_category.rb
index 67565039acd..295304f6e99 100644
--- a/app/models/time_tracking/timelog_category.rb
+++ b/app/models/time_tracking/timelog_category.rb
@@ -9,6 +9,8 @@ module TimeTracking
belongs_to :namespace, foreign_key: 'namespace_id'
+ has_many :timelogs
+
strip_attributes! :name
validates :namespace, presence: true
diff --git a/app/models/timelog.rb b/app/models/timelog.rb
index 0ae7790eef9..ffb88b7ebea 100644
--- a/app/models/timelog.rb
+++ b/app/models/timelog.rb
@@ -20,6 +20,7 @@ class Timelog < ApplicationRecord
belongs_to :project
belongs_to :user
belongs_to :note
+ belongs_to :timelog_category, optional: true, class_name: 'TimeTracking::TimelogCategory'
scope :in_group, -> (group) do
joins(:project).where(projects: { namespace: group.self_and_descendants })
diff --git a/app/services/clusters/agents/authorizations/user_access/refresh_service.rb b/app/services/clusters/agents/authorizations/user_access/refresh_service.rb
index 7efa95739fb..4c3d059777a 100644
--- a/app/services/clusters/agents/authorizations/user_access/refresh_service.rb
+++ b/app/services/clusters/agents/authorizations/user_access/refresh_service.rb
@@ -59,7 +59,7 @@ module Clusters
return unless project_entries
- allowed_projects.where_full_path_in(project_entries.keys, use_includes: false).map do |project|
+ allowed_projects.where_full_path_in(project_entries.keys, preload_routes: false).map do |project|
{ project_id: project.id, config: user_access_as }
end
end
@@ -70,7 +70,7 @@ module Clusters
return unless group_entries
- allowed_groups.where_full_path_in(group_entries.keys, use_includes: false).map do |group|
+ allowed_groups.where_full_path_in(group_entries.keys, preload_routes: false).map do |group|
{ group_id: group.id, config: user_access_as }
end
end