Commit 699986bb authored by Lin Jen-Shin's avatar Lin Jen-Shin

Extract a do_execute method to be overridden

This way we don't have to duplicate the guard
parent a6f7112c
...@@ -5,6 +5,12 @@ module MergeRequests ...@@ -5,6 +5,12 @@ module MergeRequests
def execute(oldrev, newrev, ref) def execute(oldrev, newrev, ref)
return true unless Gitlab::Git.branch_ref?(ref) return true unless Gitlab::Git.branch_ref?(ref)
do_execute(oldrev, newrev, ref)
end
private
def do_execute(oldrev, newrev, ref)
@oldrev, @newrev = oldrev, newrev @oldrev, @newrev = oldrev, newrev
@branch_name = Gitlab::Git.ref_name(ref) @branch_name = Gitlab::Git.ref_name(ref)
...@@ -30,8 +36,6 @@ module MergeRequests ...@@ -30,8 +36,6 @@ module MergeRequests
true true
end end
private
def close_upon_missing_source_branch_ref def close_upon_missing_source_branch_ref
# MergeRequest#reload_diff ignores not opened MRs. This means it won't # MergeRequest#reload_diff ignores not opened MRs. This means it won't
# create an `empty` diff for `closed` MRs without a source branch, keeping # create an `empty` diff for `closed` MRs without a source branch, keeping
......
...@@ -3,15 +3,13 @@ module EE ...@@ -3,15 +3,13 @@ module EE
module RefreshService module RefreshService
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
override :execute private
def execute(oldrev, newrev, ref)
return true unless ::Gitlab::Git.branch_ref?(ref)
override :do_execute
def do_execute(oldrev, newrev, ref)
super && reset_approvals_for_merge_requests(ref, newrev) super && reset_approvals_for_merge_requests(ref, newrev)
end end
private
# Note: Closed merge requests also need approvals reset. # Note: Closed merge requests also need approvals reset.
def reset_approvals_for_merge_requests(ref, newrev) def reset_approvals_for_merge_requests(ref, newrev)
branch_name = ::Gitlab::Git.ref_name(ref) branch_name = ::Gitlab::Git.ref_name(ref)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment