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
0
Merge Requests
0
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
Kazuhiko Shiozaki
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
Show 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
...
@@ -7,10 +7,9 @@ module MergeRequests
@branch_name
=
Gitlab
::
Git
.
ref_name
(
ref
)
@branch_name
=
Gitlab
::
Git
.
ref_name
(
ref
)
@fork_merge_requests
=
@project
.
fork_merge_requests
.
opened
@fork_merge_requests
=
@project
.
fork_merge_requests
.
opened
@commits
=
[]
@commits
=
[]
@source_merge_requests
=
merge_requests_for_source_branch
# Leave a system note if a branch were deleted/added
# 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
presence
=
Gitlab
::
Git
.
blank_ref?
(
oldrev
)
?
:add
:
:delete
comment_mr_branch_presence_changed
(
presence
)
comment_mr_branch_presence_changed
(
presence
)
else
else
...
@@ -81,7 +80,7 @@ module MergeRequests
...
@@ -81,7 +80,7 @@ module MergeRequests
# Add comment about branches being deleted or added to merge requests
# Add comment about branches being deleted or added to merge requests
def
comment_mr_branch_presence_changed
(
presence
)
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
(
SystemNoteService
.
change_branch_presence
(
merge_request
,
merge_request
.
project
,
@current_user
,
merge_request
,
merge_request
.
project
,
@current_user
,
:source
,
@branch_name
,
presence
)
:source
,
@branch_name
,
presence
)
...
@@ -90,7 +89,7 @@ module MergeRequests
...
@@ -90,7 +89,7 @@ module MergeRequests
# Add comment about pushing new commits to merge requests
# Add comment about pushing new commits to merge requests
def
comment_mr_with_commits
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
))
mr_commit_ids
=
Set
.
new
(
merge_request
.
commits
.
map
(
&
:id
))
new_commits
,
existing_commits
=
@commits
.
partition
do
|
commit
|
new_commits
,
existing_commits
=
@commits
.
partition
do
|
commit
|
...
@@ -105,7 +104,7 @@ module MergeRequests
...
@@ -105,7 +104,7 @@ module MergeRequests
# Call merge request webhook with update branches
# Call merge request webhook with update branches
def
execute_mr_web_hooks
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'
)
execute_hooks
(
merge_request
,
'update'
)
end
end
end
end
...
@@ -115,9 +114,11 @@ module MergeRequests
...
@@ -115,9 +114,11 @@ module MergeRequests
end
end
def
merge_requests_for_source_branch
def
merge_requests_for_source_branch
@source_merge_requests
||=
begin
merge_requests
=
@project
.
origin_merge_requests
.
opened
.
where
(
source_branch:
@branch_name
).
to_a
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
merge_requests
+=
@fork_merge_requests
.
where
(
source_branch:
@branch_name
).
to_a
filter_merge_requests
(
merge_requests
)
filter_merge_requests
(
merge_requests
)
end
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