summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-05-20 17:14:22 -0500
committerDouwe Maan <douwe@selenight.nl>2016-05-20 17:14:22 -0500
commitec86644545c1c2567dfaacb6d53d150a5dfa28d6 (patch)
tree1446dee382b4bb3fc80e2021041268c19ce751d8 /app/models
parentbaccd1838c92a0d38d3f38b93e9911c97adfef21 (diff)
parentab96ca2bf1ae72817ff5cedf1792c8f7563ebdef (diff)
downloadgitlab-ce-ec86644545c1c2567dfaacb6d53d150a5dfa28d6.tar.gz
Merge branch 'zj-gitignore-dropdown'
Diffstat (limited to 'app/models')
-rw-r--r--app/models/repository.rb26
1 files changed, 19 insertions, 7 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 47a7223c723..ecc8795c954 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -245,7 +245,7 @@ class Repository
def cache_keys
%i(size branch_names tag_names commit_count
readme version contribution_guide changelog
- license_blob license_key)
+ license_blob license_key gitignore)
end
def build_cache
@@ -256,6 +256,10 @@ class Repository
end
end
+ def expire_gitignore
+ cache.expire(:gitignore)
+ end
+
def expire_tags_cache
cache.expire(:tag_names)
@tags = nil
@@ -472,9 +476,7 @@ class Repository
def changelog
cache.fetch(:changelog) do
- tree(:head).blobs.find do |file|
- file.name =~ /\A(changelog|history|changes|news)/i
- end
+ file_on_head(/\A(changelog|history|changes|news)/i)
end
end
@@ -482,9 +484,7 @@ class Repository
return nil unless head_exists?
cache.fetch(:license_blob) do
- tree(:head).blobs.find do |file|
- file.name =~ /\A(licen[sc]e|copying)(\..+|\z)/i
- end
+ file_on_head(/\A(licen[sc]e|copying)(\..+|\z)/i)
end
end
@@ -496,6 +496,14 @@ class Repository
end
end
+ def gitignore
+ return nil if !exists? || empty?
+
+ cache.fetch(:gitignore) do
+ file_on_head(/\A\.gitignore\z/)
+ end
+ end
+
def gitlab_ci_yml
return nil unless head_exists?
@@ -989,4 +997,8 @@ class Repository
def head_exists?
exists? && !empty? && !rugged.head_unborn?
end
+
+ def file_on_head(regex)
+ tree(:head).blobs.find { |file| file.name =~ regex }
+ end
end