summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-07-03 19:58:58 -0400
committerDouwe Maan <douwe@selenight.nl>2016-07-04 00:11:33 -0400
commit3286dd7a1db69460573a5fd2c9e997039b1f406b (patch)
treefba63dd375acb038a1e27f03eb9ba7530578cefd /app/models/note.rb
parent0ccdc631e6f45c0fd327631decb47f80d781302e (diff)
downloadgitlab-ce-3286dd7a1db69460573a5fd2c9e997039b1f406b.tar.gz
Don't garbage collect commits that have related DB records like comments
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index c2bb117eb03..81b5c47b738 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -66,6 +66,7 @@ class Note < ActiveRecord::Base
end
before_validation :clear_blank_line_code!
+ after_save :keep_around_commit
class << self
def model_name
@@ -215,4 +216,10 @@ class Note < ActiveRecord::Base
original_name = note.match(Banzai::Filter::EmojiFilter.emoji_pattern)[1]
Gitlab::AwardEmoji.normalize_emoji_name(original_name)
end
+
+ private
+
+ def keep_around_commit
+ project.repository.keep_around(self.commit_id)
+ end
end