From 16ecd7c6dd642c46bda5806569032bc91d6ee70d Mon Sep 17 00:00:00 2001
From: Douwe Maan <douwe@selenight.nl>
Date: Sun, 3 Jul 2016 20:30:55 -0400
Subject: [PATCH] Document Repository#keep_around

---
 app/models/repository.rb | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/app/models/repository.rb b/app/models/repository.rb
index e3ad33a896a3..078ca8f4e136 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -207,6 +207,10 @@ def ref_exists?(ref)
     rugged.references.exist?(ref)
   end
 
+  # Makes sure a commit is kept around when Git garbage collection runs.
+  # Git GC will delete commits from the repository that are no longer in any
+  # branches or tags, but we want to keep some of these commits around, for
+  # example if they have comments or CI builds.
   def keep_around(sha)
     return unless sha && commit(sha)
 
@@ -219,10 +223,6 @@ def kept_around?(sha)
     ref_exists?(keep_around_ref_name(sha))
   end
 
-  def keep_around_ref_name(sha)
-    "refs/keep-around/#{sha}"
-  end
-
   def tag_names
     cache.fetch(:tag_names) { raw_repository.tag_names }
   end
@@ -1038,4 +1038,8 @@ def file_on_head(regex)
   def tags_sorted_by_committed_date
     tags.sort_by { |tag| commit(tag.target).committed_date }
   end
+
+  def keep_around_ref_name(sha)
+    "refs/keep-around/#{sha}"
+  end
 end
-- 
GitLab