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
9c67f4fb
Commit
9c67f4fb
authored
Oct 15, 2015
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Memoize merge request source branches
parent
effa94bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
app/services/merge_requests/refresh_service.rb
app/services/merge_requests/refresh_service.rb
+9
-8
No files found.
app/services/merge_requests/refresh_service.rb
View file @
9c67f4fb
...
...
@@ -7,10 +7,9 @@ module MergeRequests
@branch_name
=
Gitlab
::
Git
.
ref_name
(
ref
)
@fork_merge_requests
=
@project
.
fork_merge_requests
.
opened
@commits
=
[]
@source_merge_requests
=
merge_requests_for_source_branch
# Leave a system note if a branch were deleted/added
if
Gitlab
::
Git
.
blank_ref?
(
oldrev
)
or
Gitlab
::
Git
.
blank_ref?
(
newrev
)
if
Gitlab
::
Git
.
blank_ref?
(
oldrev
)
||
Gitlab
::
Git
.
blank_ref?
(
newrev
)
presence
=
Gitlab
::
Git
.
blank_ref?
(
oldrev
)
?
:add
:
:delete
comment_mr_branch_presence_changed
(
presence
)
else
...
...
@@ -81,7 +80,7 @@ module MergeRequests
# Add comment about branches being deleted or added to merge requests
def
comment_mr_branch_presence_changed
(
presence
)
@source_merge_requests
.
each
do
|
merge_request
|
merge_requests_for_source_branch
.
each
do
|
merge_request
|
SystemNoteService
.
change_branch_presence
(
merge_request
,
merge_request
.
project
,
@current_user
,
:source
,
@branch_name
,
presence
)
...
...
@@ -90,7 +89,7 @@ module MergeRequests
# Add comment about pushing new commits to merge requests
def
comment_mr_with_commits
@source_merge_requests
.
each
do
|
merge_request
|
merge_requests_for_source_branch
.
each
do
|
merge_request
|
mr_commit_ids
=
Set
.
new
(
merge_request
.
commits
.
map
(
&
:id
))
new_commits
,
existing_commits
=
@commits
.
partition
do
|
commit
|
...
...
@@ -105,7 +104,7 @@ module MergeRequests
# Call merge request webhook with update branches
def
execute_mr_web_hooks
@source_merge_requests
.
each
do
|
merge_request
|
merge_requests_for_source_branch
.
each
do
|
merge_request
|
execute_hooks
(
merge_request
,
'update'
)
end
end
...
...
@@ -115,9 +114,11 @@ module MergeRequests
end
def
merge_requests_for_source_branch
merge_requests
=
@project
.
origin_merge_requests
.
opened
.
where
(
source_branch:
@branch_name
).
to_a
merge_requests
+=
@fork_merge_requests
.
where
(
source_branch:
@branch_name
).
to_a
filter_merge_requests
(
merge_requests
)
@source_merge_requests
||=
begin
merge_requests
=
@project
.
origin_merge_requests
.
opened
.
where
(
source_branch:
@branch_name
).
to_a
merge_requests
+=
@fork_merge_requests
.
where
(
source_branch:
@branch_name
).
to_a
filter_merge_requests
(
merge_requests
)
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