summaryrefslogtreecommitdiff
path: root/app/models/sent_notification.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/sent_notification.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/sent_notification.rb')
-rw-r--r--app/models/sent_notification.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/sent_notification.rb b/app/models/sent_notification.rb
index 375f195dba7..a2df899d012 100644
--- a/app/models/sent_notification.rb
+++ b/app/models/sent_notification.rb
@@ -9,6 +9,8 @@ class SentNotification < ActiveRecord::Base
validates :commit_id, presence: true, if: :for_commit?
validates :line_code, line_code: true, allow_blank: true
+ after_save :keep_around_commit
+
class << self
def reply_key
SecureRandom.hex(16)
@@ -67,4 +69,10 @@ class SentNotification < ActiveRecord::Base
def to_param
self.reply_key
end
+
+ private
+
+ def keep_around_commit
+ project.repository.keep_around(self.commit_id)
+ end
end