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
e8c72354
Commit
e8c72354
authored
Mar 09, 2016
by
Baldinof
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Close merge requests when removing fork relation
parent
29ac9f64
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
2 deletions
+33
-2
CHANGELOG
CHANGELOG
+1
-0
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-1
app/models/merge_request.rb
app/models/merge_request.rb
+1
-0
app/models/project.rb
app/models/project.rb
+11
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+19
-0
No files found.
CHANGELOG
View file @
e8c72354
...
...
@@ -26,6 +26,7 @@ v 8.6.0 (unreleased)
- Show labels in dashboard and group milestone views
- Add main language of a project in the list of projects (Tiago Botelho)
- Add ability to show archived projects on dashboard, explore and group pages
- Remove fork link closes all merge requests opened on source project (Florent Baldino)
v 8.5.5
- Ensure removing a project removes associated Todo entries
...
...
app/controllers/projects_controller.rb
View file @
e8c72354
...
...
@@ -72,7 +72,7 @@ class ProjectsController < ApplicationController
def
remove_fork
return
access_denied!
unless
can?
(
current_user
,
:remove_fork_project
,
@project
)
if
@project
.
unlink_fork
if
@project
.
unlink_fork
(
current_user
)
flash
[
:notice
]
=
'The fork relationship has been removed.'
end
end
...
...
app/models/merge_request.rb
View file @
e8c72354
...
...
@@ -137,6 +137,7 @@ class MergeRequest < ActiveRecord::Base
scope
:by_milestone
,
->
(
milestone
)
{
where
(
milestone_id:
milestone
)
}
scope
:in_projects
,
->
(
project_ids
)
{
where
(
"source_project_id in (:project_ids) OR target_project_id in (:project_ids)"
,
project_ids:
project_ids
)
}
scope
:of_projects
,
->
(
ids
)
{
where
(
target_project_id:
ids
)
}
scope
:from_project
,
->
(
project
)
{
where
(
source_project_id:
project
.
id
)
}
scope
:merged
,
->
{
with_state
(
:merged
)
}
scope
:closed_and_merged
,
->
{
with_states
(
:closed
,
:merged
)
}
...
...
app/models/project.rb
View file @
e8c72354
...
...
@@ -890,12 +890,22 @@ class Project < ActiveRecord::Base
self
.
builds_enabled
=
true
end
def
unlink_fork
def
unlink_fork
(
user
)
if
forked?
forked_from_project
.
lfs_objects
.
find_each
do
|
lfs_object
|
lfs_object
.
projects
<<
self
end
merge_requests
=
forked_from_project
.
merge_requests
.
opened
.
from_project
(
self
)
unless
merge_requests
.
empty?
close_service
=
MergeRequests
::
CloseService
.
new
(
self
,
user
)
merge_requests
.
each
do
|
mr
|
close_service
.
execute
(
mr
)
end
end
forked_project_link
.
destroy
end
end
...
...
spec/models/project_spec.rb
View file @
e8c72354
...
...
@@ -647,4 +647,23 @@ describe Project, models: true do
project
.
expire_caches_before_rename
(
'foo'
)
end
end
describe
'#unlink_fork'
do
let
(
:fork_link
)
{
create
(
:forked_project_link
)
}
let
(
:fork_project
)
{
fork_link
.
forked_to_project
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
fork_project
,
target_project:
fork_link
.
forked_from_project
)
}
let!
(
:close_service
)
{
MergeRequests
::
CloseService
.
new
(
fork_project
,
user
)
}
it
'remove fork relation and close all pending merge requests'
do
allow
(
MergeRequests
::
CloseService
).
to
receive
(
:new
).
with
(
fork_project
,
user
).
and_return
(
close_service
)
expect
(
close_service
).
to
receive
(
:execute
).
with
(
merge_request
)
expect
(
fork_project
.
forked_project_link
).
to
receive
(
:destroy
)
fork_project
.
unlink_fork
(
user
)
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