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
dbfedb5a
Commit
dbfedb5a
authored
7 years ago
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check MR state before submitting queries for discussion state
parent
1f309b69
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
3 deletions
+23
-3
app/models/merge_request.rb
app/models/merge_request.rb
+2
-2
app/serializers/merge_request_widget_entity.rb
app/serializers/merge_request_widget_entity.rb
+12
-1
changelogs/unreleased/osw-short-circuit-mergeable-disccusions-state.yml
...eleased/osw-short-circuit-mergeable-disccusions-state.yml
+5
-0
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+4
-0
No files found.
app/models/merge_request.rb
View file @
dbfedb5a
...
...
@@ -618,12 +618,12 @@ class MergeRequest < ActiveRecord::Base
can_be_merged?
&&
!
should_be_rebased?
end
def
mergeable_state?
(
skip_ci_check:
false
)
def
mergeable_state?
(
skip_ci_check:
false
,
skip_discussions_check:
false
)
return
false
unless
open
?
return
false
if
work_in_progress?
return
false
if
broken?
return
false
unless
skip_ci_check
||
mergeable_ci_state?
return
false
unless
mergeable_discussions_state?
return
false
unless
skip_discussions_check
||
mergeable_discussions_state?
true
end
...
...
This diff is collapsed.
Click to expand it.
app/serializers/merge_request_widget_entity.rb
View file @
dbfedb5a
...
...
@@ -48,7 +48,18 @@ class MergeRequestWidgetEntity < IssuableEntity
expose
:merge_ongoing?
,
as: :merge_ongoing
expose
:work_in_progress?
,
as: :work_in_progress
expose
:source_branch_exists?
,
as: :source_branch_exists
expose
:mergeable_discussions_state?
,
as: :mergeable_discussions_state
expose
:mergeable_discussions_state?
,
as: :mergeable_discussions_state
do
|
merge_request
|
# This avoids calling MergeRequest#mergeable_discussions_state without
# considering the state of the MR first. If a MR isn't mergeable, we can
# safely short-circuit it.
if
merge_request
.
mergeable_state?
(
skip_ci_check:
true
,
skip_discussions_check:
true
)
merge_request
.
mergeable_discussions_state?
else
false
end
end
expose
:branch_missing?
,
as: :branch_missing
expose
:commits_count
expose
:cannot_be_merged?
,
as: :has_conflicts
...
...
This diff is collapsed.
Click to expand it.
changelogs/unreleased/osw-short-circuit-mergeable-disccusions-state.yml
0 → 100644
View file @
dbfedb5a
---
title
:
Stop checking if discussions are in a mergeable state if the MR isn't
merge_request
:
author
:
type
:
performance
This diff is collapsed.
Click to expand it.
spec/models/merge_request_spec.rb
View file @
dbfedb5a
...
...
@@ -1339,6 +1339,10 @@ describe MergeRequest do
it
'returns false'
do
expect
(
subject
.
mergeable_state?
).
to
be_falsey
end
it
'returns true when skipping discussions check'
do
expect
(
subject
.
mergeable_state?
(
skip_discussions_check:
true
)).
to
be
(
true
)
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
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