diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-11-11 15:52:30 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-11-11 15:52:30 +0300 |
commit | ccd842c3a7742d1d99a13a32ea725032810f2690 (patch) | |
tree | b96b3bd4334b831f758a88922d136deaccff0557 | |
parent | c6bc57c1a79a7add81c484d65d9795bec721e7e2 (diff) |
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: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | app/models/project.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index c58c9b551c9..1383bf3c46e 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -411,7 +411,7 @@ class Project < ActiveRecord::Base 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.uniq.each do |merge_request| + mrs.uniq.select(&:source_project).each do |merge_request| MergeRequests::MergeService.new.execute(merge_request, user, nil) end @@ -420,7 +420,7 @@ class Project < ActiveRecord::Base # Update code for merge requests between project and project fork 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.mark_as_unchecked end @@ -435,7 +435,7 @@ class Project < ActiveRecord::Base 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.uniq.each do |merge_request| + mrs.uniq.select(&:source_project).each do |merge_request| Note.create_new_commits_note(merge_request, merge_request.project, user, commits) end |