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
61de2179
Commit
61de2179
authored
Dec 30, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Approvals are not reset after a new push is made if the request is coming from a fork
parent
b6add255
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
10 deletions
+8
-10
CHANGELOG-EE
CHANGELOG-EE
+1
-0
app/services/merge_requests/refresh_service.rb
app/services/merge_requests/refresh_service.rb
+3
-6
spec/services/merge_requests/refresh_service_spec.rb
spec/services/merge_requests/refresh_service_spec.rb
+4
-4
No files found.
CHANGELOG-EE
View file @
61de2179
v 8.4.0 (unreleased)
v 8.4.0 (unreleased)
- Add ability to create a note for user by admin
- Add ability to create a note for user by admin
- Fix "Commit was rejected by git hook", when max_file_size was set null in project's Git hooks
- Fix "Commit was rejected by git hook", when max_file_size was set null in project's Git hooks
- Fix "Approvals are not reset after a new push is made if the request is coming from a fork"
v 8.3.2
v 8.3.2
- No EE-specific changes
- No EE-specific changes
...
...
app/services/merge_requests/refresh_service.rb
View file @
61de2179
...
@@ -78,14 +78,11 @@ module MergeRequests
...
@@ -78,14 +78,11 @@ module MergeRequests
end
end
# Reset approvals for merge request
# Reset approvals for merge request
# Note: we should reset approvals for merge requests from forks too
def
reset_approvals_for_merge_requests
def
reset_approvals_for_merge_requests
if
@project
.
approvals_before_merge
.
nonzero?
&&
@project
.
reset_approvals_on_push
merge_requests_for_source_branch
.
each
do
|
merge_request
|
merge_requests
=
@project
.
merge_requests
.
opened
.
where
(
source_branch:
@branch_name
).
to_a
target_project
=
merge_request
.
target_project
merge_requests
+=
@fork_merge_requests
.
where
(
source_branch:
@branch_name
).
to_a
merge_requests
=
filter_merge_requests
(
merge_requests
)
merge_requests
.
each
do
|
merge_request
|
if
target_project
.
approvals_before_merge
.
nonzero?
&&
target_project
.
reset_approvals_on_push
merge_request
.
approvals
.
destroy_all
merge_request
.
approvals
.
destroy_all
end
end
end
end
...
...
spec/services/merge_requests/refresh_service_spec.rb
View file @
61de2179
...
@@ -55,7 +55,7 @@ describe MergeRequests::RefreshService, services: true do
...
@@ -55,7 +55,7 @@ describe MergeRequests::RefreshService, services: true do
it
{
expect
(
@merge_request
.
merge_when_build_succeeds
).
to
be_falsey
}
it
{
expect
(
@merge_request
.
merge_when_build_succeeds
).
to
be_falsey
}
it
{
expect
(
@fork_merge_request
).
to
be_open
}
it
{
expect
(
@fork_merge_request
).
to
be_open
}
it
{
expect
(
@fork_merge_request
.
notes
).
to
be_empty
}
it
{
expect
(
@fork_merge_request
.
notes
).
to
be_empty
}
it
{
expect
(
@fork_merge_request
.
approvals
).
to
be_empty
}
it
{
expect
(
@fork_merge_request
.
approvals
).
not_
to
be_empty
}
end
end
context
'push to origin repo target branch'
do
context
'push to origin repo target branch'
do
...
@@ -109,7 +109,7 @@ describe MergeRequests::RefreshService, services: true do
...
@@ -109,7 +109,7 @@ describe MergeRequests::RefreshService, services: true do
it
{
expect
(
@merge_request
.
approvals
).
not_to
be_empty
}
it
{
expect
(
@merge_request
.
approvals
).
not_to
be_empty
}
it
{
expect
(
@fork_merge_request
.
notes
.
last
.
note
).
to
include
(
'Added 4 commits'
)
}
it
{
expect
(
@fork_merge_request
.
notes
.
last
.
note
).
to
include
(
'Added 4 commits'
)
}
it
{
expect
(
@fork_merge_request
).
to
be_open
}
it
{
expect
(
@fork_merge_request
).
to
be_open
}
it
{
expect
(
@fork_merge_request
.
approvals
).
not_
to
be_empty
}
it
{
expect
(
@fork_merge_request
.
approvals
).
to
be_empty
}
end
end
context
'push to fork repo target branch'
do
context
'push to fork repo target branch'
do
...
@@ -142,7 +142,7 @@ describe MergeRequests::RefreshService, services: true do
...
@@ -142,7 +142,7 @@ describe MergeRequests::RefreshService, services: true do
end
end
context
'resetting approvals if they are enabled'
do
context
'resetting approvals if they are enabled'
do
it
"does not reset approvals if approvals_before_merge
si
disabled"
do
it
"does not reset approvals if approvals_before_merge
is
disabled"
do
@project
.
update
(
approvals_before_merge:
0
)
@project
.
update
(
approvals_before_merge:
0
)
refresh_service
=
service
.
new
(
@project
,
@user
)
refresh_service
=
service
.
new
(
@project
,
@user
)
allow
(
refresh_service
).
to
receive
(
:execute_hooks
)
allow
(
refresh_service
).
to
receive
(
:execute_hooks
)
...
@@ -152,7 +152,7 @@ describe MergeRequests::RefreshService, services: true do
...
@@ -152,7 +152,7 @@ describe MergeRequests::RefreshService, services: true do
expect
(
@merge_request
.
approvals
).
not_to
be_empty
expect
(
@merge_request
.
approvals
).
not_to
be_empty
end
end
it
"does not reset approvals if reset_approvals_on_push
si
disabled"
do
it
"does not reset approvals if reset_approvals_on_push
is
disabled"
do
@project
.
update
(
reset_approvals_on_push:
false
)
@project
.
update
(
reset_approvals_on_push:
false
)
refresh_service
=
service
.
new
(
@project
,
@user
)
refresh_service
=
service
.
new
(
@project
,
@user
)
allow
(
refresh_service
).
to
receive
(
:execute_hooks
)
allow
(
refresh_service
).
to
receive
(
:execute_hooks
)
...
...
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