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
2a72d498
Commit
2a72d498
authored
May 22, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unify app/services/merge_requests/refresh_service.rb
parent
e5ef2d82
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
17 deletions
+35
-17
app/services/merge_requests/refresh_service.rb
app/services/merge_requests/refresh_service.rb
+2
-17
ee/app/services/ee/merge_requests/refresh_service.rb
ee/app/services/ee/merge_requests/refresh_service.rb
+33
-0
No files found.
app/services/merge_requests/refresh_service.rb
View file @
2a72d498
module
MergeRequests
class
RefreshService
<
MergeRequests
::
BaseService
prepend
EE
::
MergeRequests
::
RefreshService
def
execute
(
oldrev
,
newrev
,
ref
)
return
true
unless
Gitlab
::
Git
.
branch_ref?
(
ref
)
...
...
@@ -24,7 +26,6 @@ module MergeRequests
notify_about_push
mark_mr_as_wip_from_commits
execute_mr_web_hooks
reset_approvals_for_merge_requests
true
end
...
...
@@ -97,22 +98,6 @@ module MergeRequests
merge_requests_for_source_branch
(
reload:
true
)
end
# Note: Closed merge requests also need approvals reset.
def
reset_approvals_for_merge_requests
merge_requests
=
merge_requests_for
(
@branch_name
,
mr_states:
[
:opened
,
:closed
])
merge_requests
.
each
do
|
merge_request
|
target_project
=
merge_request
.
target_project
if
target_project
.
approvals_before_merge
.
nonzero?
&&
target_project
.
reset_approvals_on_push
&&
merge_request
.
rebase_commit_sha
!=
@newrev
merge_request
.
approvals
.
delete_all
end
end
end
def
reset_merge_when_pipeline_succeeds
merge_requests_for_source_branch
.
each
(
&
:reset_merge_when_pipeline_succeeds
)
end
...
...
ee/app/services/ee/merge_requests/refresh_service.rb
0 → 100644
View file @
2a72d498
module
EE
module
MergeRequests
module
RefreshService
extend
::
Gitlab
::
Utils
::
Override
override
:execute
def
execute
(
oldrev
,
newrev
,
ref
)
return
true
unless
::
Gitlab
::
Git
.
branch_ref?
(
ref
)
super
&&
reset_approvals_for_merge_requests
(
ref
,
newrev
)
end
private
# Note: Closed merge requests also need approvals reset.
def
reset_approvals_for_merge_requests
(
ref
,
newrev
)
branch_name
=
::
Gitlab
::
Git
.
ref_name
(
ref
)
merge_requests
=
merge_requests_for
(
branch_name
,
mr_states:
[
:opened
,
:closed
])
merge_requests
.
each
do
|
merge_request
|
target_project
=
merge_request
.
target_project
if
target_project
.
approvals_before_merge
.
nonzero?
&&
target_project
.
reset_approvals_on_push
&&
merge_request
.
rebase_commit_sha
!=
newrev
merge_request
.
approvals
.
delete_all
end
end
end
end
end
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