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>2022-10-28 18:10:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-10-28 18:10:51 +0300
commit8966e39395e22465ac3ff58407868b872a3ecffe (patch)
tree63c5c6f8cef63f939ff7cabfc12d7fdb0a2bd0d1 /app
parent2ebd699ede8f213f6e8f21ba7d1d9904197b2984 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/models/merge_request_assignee.rb3
-rw-r--r--app/models/merge_request_reviewer.rb2
-rw-r--r--app/models/user.rb2
-rw-r--r--app/services/protected_branches/api_service.rb33
-rw-r--r--app/services/protected_refs/access_level_params.rb4
5 files changed, 27 insertions, 17 deletions
diff --git a/app/models/merge_request_assignee.rb b/app/models/merge_request_assignee.rb
index be3a1d42eac..3e481e35deb 100644
--- a/app/models/merge_request_assignee.rb
+++ b/app/models/merge_request_assignee.rb
@@ -1,9 +1,6 @@
# frozen_string_literal: true
class MergeRequestAssignee < ApplicationRecord
- include IgnorableColumns
- ignore_column %i[state updated_state_by_user_id], remove_with: '15.6', remove_after: '2022-10-22'
-
belongs_to :merge_request, touch: true
belongs_to :assignee, class_name: "User", foreign_key: :user_id, inverse_of: :merge_request_assignees
diff --git a/app/models/merge_request_reviewer.rb b/app/models/merge_request_reviewer.rb
index 4b5b71481d3..4abf0fa09f0 100644
--- a/app/models/merge_request_reviewer.rb
+++ b/app/models/merge_request_reviewer.rb
@@ -2,8 +2,6 @@
class MergeRequestReviewer < ApplicationRecord
include MergeRequestReviewerState
- include IgnorableColumns
- ignore_column :updated_state_by_user_id, remove_with: '15.6', remove_after: '2022-10-22'
belongs_to :merge_request
belongs_to :reviewer, class_name: 'User', foreign_key: :user_id, inverse_of: :merge_request_reviewers
diff --git a/app/models/user.rb b/app/models/user.rb
index df234a7e067..6b11a57e1f7 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -188,7 +188,7 @@ class User < ApplicationRecord
has_many :personal_projects, through: :namespace, source: :projects
has_many :project_members, -> { where(requested_at: nil) }
has_many :projects, through: :project_members
- has_many :created_projects, foreign_key: :creator_id, class_name: 'Project'
+ has_many :created_projects, foreign_key: :creator_id, class_name: 'Project', dependent: :nullify # rubocop:disable Cop/ActiveRecordDependent
has_many :projects_with_active_memberships, -> { where(members: { state: ::Member::STATE_ACTIVE }) }, through: :project_members, source: :project
has_many :users_star_projects, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :starred_projects, through: :users_star_projects, source: :project
diff --git a/app/services/protected_branches/api_service.rb b/app/services/protected_branches/api_service.rb
index f604a57bcd1..b8fe9bac13e 100644
--- a/app/services/protected_branches/api_service.rb
+++ b/app/services/protected_branches/api_service.rb
@@ -6,17 +6,32 @@ module ProtectedBranches
::ProtectedBranches::CreateService.new(@project, @current_user, protected_branch_params).execute
end
- def protected_branch_params
- {
- name: params[:name],
- allow_force_push: allow_force_push?,
- push_access_levels_attributes: ::ProtectedRefs::AccessLevelParams.new(:push, params).access_levels,
- merge_access_levels_attributes: ::ProtectedRefs::AccessLevelParams.new(:merge, params).access_levels
- }
+ def update(protected_branch)
+ ::ProtectedBranches::UpdateService.new(@project, @current_user,
+protected_branch_params(with_defaults: false)).execute(protected_branch)
end
- def allow_force_push?
- params[:allow_force_push] || false
+ private
+
+ def protected_branch_params(with_defaults: true)
+ params.slice(*attributes).merge(
+ {
+ push_access_levels_attributes: access_level_attributes(:push, with_defaults),
+ merge_access_levels_attributes: access_level_attributes(:merge, with_defaults)
+ }
+ )
+ end
+
+ def access_level_attributes(type, with_defaults)
+ ::ProtectedRefs::AccessLevelParams.new(
+ type,
+ params,
+ with_defaults: with_defaults
+ ).access_levels
+ end
+
+ def attributes
+ [:name, :allow_force_push]
end
end
end
diff --git a/app/services/protected_refs/access_level_params.rb b/app/services/protected_refs/access_level_params.rb
index 59fc17868d1..a421964a6ab 100644
--- a/app/services/protected_refs/access_level_params.rb
+++ b/app/services/protected_refs/access_level_params.rb
@@ -4,9 +4,9 @@ module ProtectedRefs
class AccessLevelParams
attr_reader :type, :params
- def initialize(type, params)
+ def initialize(type, params, with_defaults: true)
@type = type
- @params = params_with_default(params)
+ @params = with_defaults ? params_with_default(params) : params
end
def access_levels