Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
489c337b
Commit
489c337b
authored
Jan 03, 2019
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove further unused code
Related to removing finalize MR
parent
b855cb6b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
37 deletions
+4
-37
ee/lib/gitlab/background_migration/migrate_approver_to_approval_rules.rb
...ackground_migration/migrate_approver_to_approval_rules.rb
+3
-36
ee/spec/lib/gitlab/background_migration/migrate_approver_to_approval_rules_check_progress_spec.rb
...migrate_approver_to_approval_rules_check_progress_spec.rb
+1
-1
No files found.
ee/lib/gitlab/background_migration/migrate_approver_to_approval_rules.rb
View file @
489c337b
...
...
@@ -3,7 +3,7 @@
module
Gitlab
module
BackgroundMigration
# A Project/MergeRequest level migration, aiming to convert existing data
# (from approvers, approver_groups
and approvals
tables)
# (from approvers, approver_groups tables)
# to new rule based schema.
class
MigrateApproverToApprovalRules
include
Gitlab
::
Utils
::
StrongMemoize
...
...
@@ -16,7 +16,7 @@ module Gitlab
self
.
table_name
=
'approver_groups'
end
class
ApprovalMergeRequestRule
<
A
pplicationRecord
class
ApprovalMergeRequestRule
<
A
ctiveRecord
::
Base
self
.
table_name
=
'approval_merge_request_rules'
include
Gitlab
::
Utils
::
StrongMemoize
...
...
@@ -27,38 +27,15 @@ module Gitlab
has_and_belongs_to_many
:users
has_and_belongs_to_many
:groups
,
class_name:
'Group'
,
join_table: :approval_merge_request_rules_groups
has_and_belongs_to_many
:approvals
# This is only populated after merge request is merged
has_many
:approved_approvers
,
through: :approvals
,
source: :user
has_one
:approval_merge_request_rule_source
has_one
:approval_project_rule
,
through: :approval_merge_request_rule_source
def
project
merge_request
.
target_project
end
# Users who are eligible to approve, including specified group members.
# Excludes the author if 'self-approval' isn't explicitly
# enabled on project settings.
# @return [Array<User>]
def
approvers
strong_memoize
(
:approvers
)
do
scope
=
User
.
from_union
(
[
users
,
User
.
joins
(
:group_members
).
where
(
members:
{
source_id:
groups
})
]
)
if
merge_request
.
author
&&
!
project
.
merge_requests_author_approval?
scope
=
scope
.
where
.
not
(
id:
merge_request
.
author
)
end
scope
end
end
end
class
ApprovalMergeRequestRuleSource
<
ApplicationRecord
class
ApprovalMergeRequestRuleSource
<
ActiveRecord
::
Base
self
.
table_name
=
'approval_merge_request_rule_sources'
belongs_to
:approval_merge_request_rule
belongs_to
:approval_project_rule
...
...
@@ -79,9 +56,7 @@ module Gitlab
include
::
EachBatch
belongs_to
:target_project
,
class_name:
"Project"
belongs_to
:author
,
class_name:
"User"
has_many
:approval_rules
,
class_name:
'ApprovalMergeRequestRule'
has_many
:approvals
def
approvers
Approver
.
where
(
target_type:
'MergeRequest'
,
target_id:
id
)
...
...
@@ -91,10 +66,6 @@ module Gitlab
ApproverGroup
.
where
(
target_type:
'MergeRequest'
,
target_id:
id
)
end
def
merged?
state
==
'merged'
end
def
sync_code_owners_with_approvers
::
MergeRequest
.
find
(
id
).
sync_code_owners_with_approvers
end
...
...
@@ -116,11 +87,7 @@ module Gitlab
end
class
User
<
ActiveRecord
::
Base
include
FromUnion
self
.
table_name
=
'users'
has_many
:group_members
,
->
{
where
(
requested_at:
nil
)
},
source:
'GroupMember'
end
ALLOWED_TARGET_TYPES
=
%w{MergeRequest Project}
.
freeze
...
...
ee/spec/lib/gitlab/background_migration/migrate_approver_to_approval_rules_check_progress_spec.rb
View file @
489c337b
...
...
@@ -17,7 +17,7 @@ describe Gitlab::BackgroundMigration::MigrateApproverToApprovalRulesCheckProgres
it
'enables feature'
do
allow
(
Gitlab
::
BackgroundMigration
).
to
receive
(
:exists?
).
with
(
'MigrateApproverToApprovalRulesInBatch'
).
and_return
(
false
)
expect
(
Feature
).
to
receive
(
:enable
).
and_return
(
:approval_rule
)
expect
(
Feature
).
to
receive
(
:enable
).
with
(
:approval_rule
)
described_class
.
new
.
perform
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment