2016-03-22 10:34:35 -04:00
|
|
|
module Projects
|
|
|
|
class UnlinkForkService < BaseService
|
|
|
|
def execute
|
|
|
|
return unless @project.forked?
|
|
|
|
|
|
|
|
@project.forked_from_project.lfs_objects.find_each do |lfs_object|
|
2016-04-04 10:41:01 -04:00
|
|
|
lfs_object.projects << @project
|
2016-03-22 10:34:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
merge_requests = @project.forked_from_project.merge_requests.opened.from_project(@project)
|
|
|
|
|
|
|
|
merge_requests.each do |mr|
|
2017-06-13 18:12:31 -04:00
|
|
|
::MergeRequests::CloseService.new(@project, @current_user).execute(mr)
|
2016-03-22 10:34:35 -04:00
|
|
|
end
|
|
|
|
|
2017-08-14 09:22:09 -04:00
|
|
|
refresh_forks_count(@project.forked_from_project)
|
|
|
|
|
2017-09-30 14:21:08 -04:00
|
|
|
@project.fork_network_member.destroy
|
2017-10-17 10:33:30 -04:00
|
|
|
@project.forked_project_link.destroy
|
2016-03-22 10:34:35 -04:00
|
|
|
end
|
2017-08-14 09:22:09 -04:00
|
|
|
|
|
|
|
def refresh_forks_count(project)
|
|
|
|
Projects::ForksCountService.new(project).refresh_cache
|
|
|
|
end
|
2016-03-22 10:34:35 -04:00
|
|
|
end
|
|
|
|
end
|