2016-06-02 11:05:42 +05:30
|
|
|
module Projects
|
|
|
|
class UnlinkForkService < BaseService
|
|
|
|
def execute
|
|
|
|
return unless @project.forked?
|
|
|
|
|
|
|
|
@project.forked_from_project.lfs_objects.find_each do |lfs_object|
|
|
|
|
lfs_object.projects << @project
|
|
|
|
end
|
|
|
|
|
|
|
|
merge_requests = @project.forked_from_project.merge_requests.opened.from_project(@project)
|
|
|
|
|
|
|
|
merge_requests.each do |mr|
|
2017-09-10 17:25:29 +05:30
|
|
|
::MergeRequests::CloseService.new(@project, @current_user).execute(mr)
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
refresh_forks_count(@project.forked_from_project)
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
@project.forked_project_link.destroy
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
def refresh_forks_count(project)
|
|
|
|
Projects::ForksCountService.new(project).refresh_cache
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
end
|