Commit 9ee49c5c authored by Andrew Kumanyaev's avatar Andrew Kumanyaev
Browse files

Update merge requests from fork project to origin project

Fix error described in
parent 529943cae564
......@@ -53,6 +53,7 @@ class Project < ActiveRecord::Base
has_many :services, dependent: :destroy
has_many :events, dependent: :destroy
has_many :merge_requests, dependent: :destroy, foreign_key: "target_project_id"
has_many :fork_merge_requests,dependent: :destroy, foreign_key: "source_project_id", class_name: MergeRequest
has_many :issues, dependent: :destroy, order: "state DESC, created_at DESC"
has_many :milestones, dependent: :destroy
has_many :notes, dependent: :destroy
......@@ -312,8 +313,11 @@ def update_merge_requests(oldrev, newrev, ref, user)
branch_name = ref.gsub("refs/heads/", "")
c_ids = self.repository.commits_between(oldrev, newrev).map(&:id)
# Update code for merge requests
# Update code for merge requests into project between project branches
mrs = self.merge_requests.opened.by_branch(branch_name).all
# Update code for merge requests between project and project fork
mrs += self.fork_merge_requests.opened.by_branch(branch_name).all
mrs.each { |merge_request| merge_request.reload_code; merge_request.mark_as_unchecked }
# Close merge requests
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