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
267703e2
Commit
267703e2
authored
Feb 03, 2019
by
Paul Slaughter
Committed by
Mark Chao
Feb 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BE expose use_fallback
parent
651d8a22
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
ee/app/models/approval_state.rb
ee/app/models/approval_state.rb
+8
-4
ee/lib/ee/api/entities.rb
ee/lib/ee/api/entities.rb
+3
-0
No files found.
ee/app/models/approval_state.rb
View file @
267703e2
...
...
@@ -39,6 +39,10 @@ class ApprovalState
!
wrapped_approval_rules
.
empty?
end
def
use_fallback?
regular_rules
.
empty?
end
def
approval_rules_overwritten?
merge_request
.
approval_rules
.
any?
(
&
:regular?
)
end
...
...
@@ -48,7 +52,7 @@ class ApprovalState
return
false
unless
project
.
feature_available?
(
:merge_request_approvers
)
result
=
wrapped_approval_rules
.
any?
{
|
rule
|
rule
.
approvals_required
>
0
}
result
||=
fallback_approvals_required
>
0
if
regular_rules
.
empty
?
result
||=
fallback_approvals_required
>
0
if
use_fallback
?
result
end
...
...
@@ -59,7 +63,7 @@ class ApprovalState
def
approved?
strong_memoize
(
:approved
)
do
result
=
wrapped_approval_rules
.
all?
(
&
:approved?
)
result
&&=
approvals
.
size
>=
fallback_approvals_required
if
regular_rules
.
empty
?
result
&&=
approvals
.
size
>=
fallback_approvals_required
if
use_fallback
?
result
end
end
...
...
@@ -71,7 +75,7 @@ class ApprovalState
def
approvals_required
strong_memoize
(
:approvals_required
)
do
result
=
wrapped_approval_rules
.
sum
(
&
:approvals_required
)
result
=
[
result
,
fallback_approvals_required
].
max
if
regular_rules
.
empty
?
result
=
[
result
,
fallback_approvals_required
].
max
if
use_fallback
?
result
end
end
...
...
@@ -81,7 +85,7 @@ class ApprovalState
def
approvals_left
strong_memoize
(
:approvals_left
)
do
result
=
wrapped_approval_rules
.
sum
(
&
:approvals_left
)
result
=
[
result
,
fallback_approvals_required
-
approved_approvers
.
size
].
max
if
regular_rules
.
empty
?
result
=
[
result
,
fallback_approvals_required
-
approved_approvers
.
size
].
max
if
use_fallback
?
result
end
end
...
...
ee/lib/ee/api/entities.rb
View file @
267703e2
...
...
@@ -274,6 +274,9 @@ module EE
expose
:wrapped_approval_rules
,
as: :rules
,
using:
MergeRequestApprovalRule
expose
:fallback_approvals_required
expose
:use_fallback
do
|
approval_state
|
approval_state
.
use_fallback?
end
end
# Decorates Project
...
...
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