summaryrefslogtreecommitdiff
path: root/app/services/projects/unlink_fork_service.rb
diff options
context:
space:
mode:
authorBaldinof <baldinof@gmail.com>2016-03-22 15:34:35 +0100
committerBaldinof <baldinof@gmail.com>2016-03-22 15:34:35 +0100
commitfa4126acffdfe13741e05a60ad5ed7fd407b4f16 (patch)
treeb7f7e6e49d851c947426684def13c593896f0c70 /app/services/projects/unlink_fork_service.rb
parent436caf4e8b7beb8cb61bb1045273488477841880 (diff)
downloadgitlab-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.rb19
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