BigW Consortium Gitlab

Commit 18a5bb05 by Douwe Maan

Store diff head and start commit shas on MR diffs

parent c66a7b0e
...@@ -24,7 +24,7 @@ class MergeRequestDiff < ActiveRecord::Base ...@@ -24,7 +24,7 @@ class MergeRequestDiff < ActiveRecord::Base
serialize :st_diffs serialize :st_diffs
after_create :reload_content, unless: :importing? after_create :reload_content, unless: :importing?
after_save :keep_around_commit after_save :keep_around_commits
def reload_content def reload_content
reload_commits reload_commits
...@@ -147,12 +147,13 @@ class MergeRequestDiff < ActiveRecord::Base ...@@ -147,12 +147,13 @@ class MergeRequestDiff < ActiveRecord::Base
new_attributes[:st_diffs] = new_diffs new_attributes[:st_diffs] = new_diffs
base_commit_sha = self.repository.merge_base(self.head, self.base) new_attributes[:start_commit_sha] = self.target_branch_sha
new_attributes[:base_commit_sha] = base_commit_sha new_attributes[:head_commit_sha] = self.source_branch_sha
new_attributes[:base_commit_sha] = branch_base_sha
self.repository.keep_around(base_commit_sha)
update_columns_serialized(new_attributes) update_columns_serialized(new_attributes)
keep_around_commits
end end
# Collect array of Git::Diff objects # Collect array of Git::Diff objects
...@@ -223,7 +224,9 @@ class MergeRequestDiff < ActiveRecord::Base ...@@ -223,7 +224,9 @@ class MergeRequestDiff < ActiveRecord::Base
reload reload
end end
def keep_around_commit def keep_around_commits
self.repository.keep_around(self.base_commit_sha) self.repository.keep_around(target_branch_sha)
self.repository.keep_around(source_branch_sha)
self.repository.keep_around(branch_base_sha)
end end
end end
class AddHeadCommitIdToMergeRequestDiffs < ActiveRecord::Migration
def change
add_column :merge_request_diffs, :head_commit_sha, :string
end
end
class AddStartCommitIdToMergeRequestDiffs < ActiveRecord::Migration
def change
add_column :merge_request_diffs, :start_commit_sha, :string
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