Commit ccd842c3 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Prevent post-receive error when push to project with dead forks

If project has open merge request from fork and this fork was removed
before merge request was closed it cause exception during push
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent c6bc57c1
...@@ -411,7 +411,7 @@ class Project < ActiveRecord::Base ...@@ -411,7 +411,7 @@ class Project < ActiveRecord::Base
mrs = self.merge_requests.opened.where(target_branch: branch_name).to_a mrs = self.merge_requests.opened.where(target_branch: branch_name).to_a
mrs = mrs.select(&:last_commit).select { |mr| c_ids.include?(mr.last_commit.id) } mrs = mrs.select(&:last_commit).select { |mr| c_ids.include?(mr.last_commit.id) }
mrs.uniq.each do |merge_request| mrs.uniq.select(&:source_project).each do |merge_request|
MergeRequests::MergeService.new.execute(merge_request, user, nil) MergeRequests::MergeService.new.execute(merge_request, user, nil)
end end
...@@ -420,7 +420,7 @@ class Project < ActiveRecord::Base ...@@ -420,7 +420,7 @@ class Project < ActiveRecord::Base
# Update code for merge requests between project and project fork # Update code for merge requests between project and project fork
mrs += self.fork_merge_requests.opened.by_branch(branch_name).to_a mrs += self.fork_merge_requests.opened.by_branch(branch_name).to_a
mrs.uniq.each do |merge_request| mrs.uniq.select(&:source_project).each do |merge_request|
merge_request.reload_code merge_request.reload_code
merge_request.mark_as_unchecked merge_request.mark_as_unchecked
end end
...@@ -435,7 +435,7 @@ class Project < ActiveRecord::Base ...@@ -435,7 +435,7 @@ class Project < ActiveRecord::Base
mrs = self.origin_merge_requests.opened.where(source_branch: branch_name).to_a mrs = self.origin_merge_requests.opened.where(source_branch: branch_name).to_a
mrs += self.fork_merge_requests.opened.where(source_branch: branch_name).to_a mrs += self.fork_merge_requests.opened.where(source_branch: branch_name).to_a
mrs.uniq.each do |merge_request| mrs.uniq.select(&:source_project).each do |merge_request|
Note.create_new_commits_note(merge_request, merge_request.project, Note.create_new_commits_note(merge_request, merge_request.project,
user, commits) user, commits)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment