Commit d7e8479e authored by Douwe Maan's avatar Douwe Maan

Keep around DiffNote position commits

parent ddec2ed0
...@@ -14,6 +14,7 @@ class DiffNote < Note ...@@ -14,6 +14,7 @@ class DiffNote < Note
before_validation :set_original_position, :update_position, on: :create before_validation :set_original_position, :update_position, on: :create
before_validation :set_line_code before_validation :set_line_code
after_save :keep_around_commits
class << self class << self
def build_discussion_id(noteable_type, noteable_id, position) def build_discussion_id(noteable_type, noteable_id, position)
...@@ -116,4 +117,16 @@ class DiffNote < Note ...@@ -116,4 +117,16 @@ class DiffNote < Note
errors.add(:position, "is invalid") errors.add(:position, "is invalid")
end end
def keep_around_commits
project.repository.keep_around(self.original_position.base_sha)
project.repository.keep_around(self.original_position.start_sha)
project.repository.keep_around(self.original_position.head_sha)
if self.position != self.original_position
project.repository.keep_around(self.position.base_sha)
project.repository.keep_around(self.position.start_sha)
project.repository.keep_around(self.position.head_sha)
end
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