diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-07 00:10:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-07 00:10:28 +0300 |
commit | a303eb5d329ee4fee3ad76b9c2e32ce1d6d4a13b (patch) | |
tree | d586f0a605912b6b4b519afca03b20e0ca0e9e65 /lib/gitlab | |
parent | 2644e59eb5a3a976d445a08727f41428647fdbec (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab')
4 files changed, 85 insertions, 0 deletions
diff --git a/lib/gitlab/background_migration/delete_invalid_protected_branch_merge_access_levels.rb b/lib/gitlab/background_migration/delete_invalid_protected_branch_merge_access_levels.rb new file mode 100644 index 00000000000..99bc638532a --- /dev/null +++ b/lib/gitlab/background_migration/delete_invalid_protected_branch_merge_access_levels.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # A job to remove protected_branch_merge_access_levels for groups that do not have project_group_links + # to the project for the associated protected branch + class DeleteInvalidProtectedBranchMergeAccessLevels < BatchedMigrationJob + operation_name :delete_invalid_protected_branch_merge_access_levels + scope_to ->(relation) { relation.where.not(group_id: nil) } + feature_category :source_code_management + + def perform + each_sub_batch do |sub_batch| + sub_batch + .joins('INNER JOIN protected_branches ON protected_branches.id = protected_branch_id') + .joins(%( + LEFT OUTER JOIN project_group_links pgl + ON pgl.group_id = protected_branch_merge_access_levels.group_id + AND pgl.project_id = protected_branches.project_id + )) + .where(%( + pgl.id IS NULL + )).delete_all + end + end + end + end +end diff --git a/lib/gitlab/background_migration/delete_invalid_protected_branch_push_access_levels.rb b/lib/gitlab/background_migration/delete_invalid_protected_branch_push_access_levels.rb new file mode 100644 index 00000000000..a6934cf5adc --- /dev/null +++ b/lib/gitlab/background_migration/delete_invalid_protected_branch_push_access_levels.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # A job to remove protected_branch_push_access_levels for groups that do not have project_group_links + # to the project for the associated protected branch + class DeleteInvalidProtectedBranchPushAccessLevels < BatchedMigrationJob + operation_name :delete_invalid_protected_branch_push_access_levels + scope_to ->(relation) { relation.where.not(group_id: nil) } + feature_category :source_code_management + + def perform + each_sub_batch do |sub_batch| + sub_batch + .joins('INNER JOIN protected_branches ON protected_branches.id = protected_branch_id') + .joins(%( + LEFT OUTER JOIN project_group_links pgl + ON pgl.group_id = protected_branch_push_access_levels.group_id + AND pgl.project_id = protected_branches.project_id + )) + .where(%( + pgl.id IS NULL + )).delete_all + end + end + end + end +end diff --git a/lib/gitlab/background_migration/delete_invalid_protected_tag_create_access_levels.rb b/lib/gitlab/background_migration/delete_invalid_protected_tag_create_access_levels.rb new file mode 100644 index 00000000000..8c59e42a9f6 --- /dev/null +++ b/lib/gitlab/background_migration/delete_invalid_protected_tag_create_access_levels.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # A job to remove protected_tag_create_access_levels for groups that do not have project_group_links + # to the project for the associated protected branch + class DeleteInvalidProtectedTagCreateAccessLevels < BatchedMigrationJob + operation_name :delete_invalid_protected_tag_create_access_levels + scope_to ->(relation) { relation.where.not(group_id: nil) } + feature_category :source_code_management + + def perform + each_sub_batch do |sub_batch| + sub_batch + .joins('INNER JOIN protected_tags ON protected_tags.id = protected_tag_id') + .joins(%( + LEFT OUTER JOIN project_group_links pgl + ON pgl.group_id = protected_tag_create_access_levels.group_id + AND pgl.project_id = protected_tags.project_id + )) + .where(%( + pgl.id IS NULL + )).delete_all + end + end + end + end +end diff --git a/lib/gitlab/push_options.rb b/lib/gitlab/push_options.rb index 4471d21b9ac..e817f2130f4 100644 --- a/lib/gitlab/push_options.rb +++ b/lib/gitlab/push_options.rb @@ -14,6 +14,7 @@ module Gitlab :milestone, :remove_source_branch, :target, + :target_project, :title, :unassign, :unlabel |