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>2023-11-07 06:10:53 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-11-07 06:10:53 +0300
commit2ce8e7fcf32b18db57a5547fda35044e55cdc1eb (patch)
tree64bbbdd27d96d158ac1642d496aeaa199dd16dd1 /app
parent611897b987d439b0d736eb87415b8ca32bdaa282 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/models/packages/tag.rb7
-rw-r--r--app/policies/ci/pipeline_policy.rb15
-rw-r--r--app/services/ci/cancel_pipeline_service.rb13
-rw-r--r--app/services/packages/update_tags_service.rb3
-rw-r--r--app/views/protected_branches/shared/_create_protected_branch.html.haml13
-rw-r--r--app/workers/bulk_imports/entity_worker.rb2
6 files changed, 32 insertions, 21 deletions
diff --git a/app/models/packages/tag.rb b/app/models/packages/tag.rb
index 9c17a147bf4..0df64bfba54 100644
--- a/app/models/packages/tag.rb
+++ b/app/models/packages/tag.rb
@@ -1,9 +1,12 @@
# frozen_string_literal: true
class Packages::Tag < ApplicationRecord
belongs_to :package, inverse_of: :tags
+ belongs_to :project
validates :package, :name, presence: true
+ before_save :ensure_project_id
+
FOR_PACKAGES_TAGS_LIMIT = 200
NUGET_TAGS_SEPARATOR = ' ' # https://docs.microsoft.com/en-us/nuget/reference/nuspec#tags
@@ -15,4 +18,8 @@ class Packages::Tag < ApplicationRecord
.order(updated_at: :desc)
.limit(FOR_PACKAGES_TAGS_LIMIT)
end
+
+ def ensure_project_id
+ self.project_id ||= package.project_id
+ end
end
diff --git a/app/policies/ci/pipeline_policy.rb b/app/policies/ci/pipeline_policy.rb
index bd6e580c33a..c01162a86df 100644
--- a/app/policies/ci/pipeline_policy.rb
+++ b/app/policies/ci/pipeline_policy.rb
@@ -27,10 +27,14 @@ module Ci
prevent :read_pipeline
end
- rule { protected_ref }.prevent :update_pipeline
+ rule { protected_ref }.policy do
+ prevent :update_pipeline
+ prevent :cancel_pipeline
+ end
rule { can?(:public_access) & branch_allows_collaboration }.policy do
enable :update_pipeline
+ enable :cancel_pipeline
end
rule { can?(:owner_access) }.policy do
@@ -45,15 +49,6 @@ module Ci
enable :read_pipeline_variable
end
- # TODO: splitting out cancel from update in Issue #20207
- rule { can?(:update_pipeline) }.policy do
- enable :cancel_pipeline
- end
-
- rule { ~can?(:update_pipeline) }.policy do
- prevent :cancel_pipeline
- end
-
rule { project_allows_read_dependency }.policy do
enable :read_dependency
end
diff --git a/app/services/ci/cancel_pipeline_service.rb b/app/services/ci/cancel_pipeline_service.rb
index 52d38520fc3..38053b13921 100644
--- a/app/services/ci/cancel_pipeline_service.rb
+++ b/app/services/ci/cancel_pipeline_service.rb
@@ -24,11 +24,7 @@ module Ci
end
def execute
- unless can?(current_user, :cancel_pipeline, pipeline)
- return ServiceResponse.error(
- message: 'Insufficient permissions to cancel the pipeline',
- reason: :insufficient_permissions)
- end
+ return permission_error_response unless can?(current_user, :cancel_pipeline, pipeline)
force_execute
end
@@ -103,6 +99,13 @@ module Ci
job.cancel
end
+ def permission_error_response
+ ServiceResponse.error(
+ message: 'Insufficient permissions to cancel the pipeline',
+ reason: :insufficient_permissions
+ )
+ end
+
# For parent child-pipelines only (not multi-project)
def cancel_children
pipeline.all_child_pipelines.each do |child_pipeline|
diff --git a/app/services/packages/update_tags_service.rb b/app/services/packages/update_tags_service.rb
index cf1acc6ee19..014d5501b76 100644
--- a/app/services/packages/update_tags_service.rb
+++ b/app/services/packages/update_tags_service.rb
@@ -32,7 +32,8 @@ module Packages
package_id: @package.id,
name: tag,
created_at: now,
- updated_at: now
+ updated_at: now,
+ project_id: @package.project_id
}
end
end
diff --git a/app/views/protected_branches/shared/_create_protected_branch.html.haml b/app/views/protected_branches/shared/_create_protected_branch.html.haml
index 96e6990b080..34ffbf498d3 100644
--- a/app/views/protected_branches/shared/_create_protected_branch.html.haml
+++ b/app/views/protected_branches/shared/_create_protected_branch.html.haml
@@ -14,12 +14,17 @@
= render partial: "protected_branches/shared/dropdown", locals: { f: f, toggle_classes: 'gl-w-full! gl-form-input-lg' }
.form-text.text-muted
- wildcards_url = help_page_url('user/project/protected_branches', anchor: 'protect-multiple-branches-with-wildcard-rules')
- - wildcards_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: wildcards_url }
- - placeholders = { wildcards_link_start: wildcards_link_start, wildcards_link_end: '</a>', code_tag_start: '<code>', code_tag_end: '</code>' }
+ - wildcards_link_tag_pair = tag_pair(link_to('', wildcards_url, target: '_blank', rel: 'noopener noreferrer'), :wildcards_link_start, :wildcards_link_end)
+
+ - case_sensitive_url = help_page_url('user/project/protected_branches', anchor: 'branch-names-are-case-sensitive')
+ - case_sensitive_link_tag_pair = tag_pair(link_to('', case_sensitive_url, target: '_blank', rel: 'noopener noreferrer'), :case_sensitive_link_start, :case_sensitive_link_end)
+
+ - code_tag_pair = tag_pair(tag.code, :code_tag_start, :code_tag_end)
+
- if protected_branch_entity.is_a?(Group)
- = (s_("ProtectedBranch|Only %{wildcards_link_start}Wildcards%{wildcards_link_end} such as %{code_tag_start}*-stable%{code_tag_end} or %{code_tag_start}production/*%{code_tag_end} are supported.") % placeholders).html_safe
+ = safe_format(s_('ProtectedBranch|Only %{wildcards_link_start}Wildcards%{wildcards_link_end} such as %{code_tag_start}*-stable%{code_tag_end} or %{code_tag_start}production/*%{code_tag_end} are supported. %{case_sensitive_link_start}Branch names are case-sensitive.%{case_sensitive_link_end}'), wildcards_link_tag_pair, case_sensitive_link_tag_pair, code_tag_pair)
- else
- = (s_("ProtectedBranch|%{wildcards_link_start}Wildcards%{wildcards_link_end} such as %{code_tag_start}*-stable%{code_tag_end} or %{code_tag_start}production/*%{code_tag_end} are supported.") % placeholders).html_safe
+ = safe_format(s_('ProtectedBranch|%{wildcards_link_start}Wildcards%{wildcards_link_end} such as %{code_tag_start}*-stable%{code_tag_end} or %{code_tag_start}production/*%{code_tag_end} are supported. %{case_sensitive_link_start}Branch names are case-sensitive.%{case_sensitive_link_end}'), wildcards_link_tag_pair, case_sensitive_link_tag_pair, code_tag_pair)
.form-group.row
= f.label :merge_access_levels_attributes, s_("ProtectedBranch|Allowed to merge:"), class: 'col-sm-12'
.col-sm-12
diff --git a/app/workers/bulk_imports/entity_worker.rb b/app/workers/bulk_imports/entity_worker.rb
index 02eee3094ad..1c426be4545 100644
--- a/app/workers/bulk_imports/entity_worker.rb
+++ b/app/workers/bulk_imports/entity_worker.rb
@@ -15,7 +15,7 @@ module BulkImports
new.perform_failure(exception, msg['args'].first)
end
- PERFORM_DELAY = 30.seconds
+ PERFORM_DELAY = 5.seconds
# Keep `_current_stage` parameter for backwards compatibility.
# The parameter will be remove in https://gitlab.com/gitlab-org/gitlab/-/issues/426311