diff options
author | Baldinof <baldinof@gmail.com> | 2016-03-22 15:34:35 +0100 |
---|---|---|
committer | Baldinof <baldinof@gmail.com> | 2016-03-22 15:34:35 +0100 |
commit | fa4126acffdfe13741e05a60ad5ed7fd407b4f16 (patch) | |
tree | b7f7e6e49d851c947426684def13c593896f0c70 /app/services/projects/unlink_fork_service.rb | |
parent | 436caf4e8b7beb8cb61bb1045273488477841880 (diff) | |
download | gitlab-ce-fa4126acffdfe13741e05a60ad5ed7fd407b4f16.tar.gz |
Move unlink fork logic to a service
Diffstat (limited to 'app/services/projects/unlink_fork_service.rb')
-rw-r--r-- | app/services/projects/unlink_fork_service.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/services/projects/unlink_fork_service.rb b/app/services/projects/unlink_fork_service.rb new file mode 100644 index 00000000000..d0703effa1d --- /dev/null +++ b/app/services/projects/unlink_fork_service.rb @@ -0,0 +1,19 @@ +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 << self + end + + merge_requests = @project.forked_from_project.merge_requests.opened.from_project(@project) + + merge_requests.each do |mr| + MergeRequests::CloseService.new(@project, @current_user).execute(mr) + end + + @project.forked_project_link.destroy + end + end +end |