Commit 2afcc9e9 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Create new version of merge request diff on push instead of updating existing one

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 2acb8a30
...@@ -10,8 +10,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -10,8 +10,7 @@ class MergeRequest < ActiveRecord::Base
belongs_to :source_project, foreign_key: :source_project_id, class_name: "Project" belongs_to :source_project, foreign_key: :source_project_id, class_name: "Project"
belongs_to :merge_user, class_name: "User" belongs_to :merge_user, class_name: "User"
has_one :merge_request_diff, dependent: :destroy has_many :merge_request_diffs, dependent: :destroy
has_many :events, as: :target, dependent: :destroy has_many :events, as: :target, dependent: :destroy
serialize :merge_params, Hash serialize :merge_params, Hash
...@@ -294,7 +293,9 @@ class MergeRequest < ActiveRecord::Base ...@@ -294,7 +293,9 @@ class MergeRequest < ActiveRecord::Base
end end
def reload_diff def reload_diff
return unless merge_request_diff && open? return unless open?
merge_request_diff = merge_request_diffs.create
old_diff_refs = self.diff_refs old_diff_refs = self.diff_refs
...@@ -691,4 +692,8 @@ class MergeRequest < ActiveRecord::Base ...@@ -691,4 +692,8 @@ class MergeRequest < ActiveRecord::Base
def keep_around_commit def keep_around_commit
project.repository.keep_around(self.merge_commit_sha) project.repository.keep_around(self.merge_commit_sha)
end end
def merge_request_diff
merge_request_diffs.first
end
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