Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-03-18 17:31:19 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2016-03-19 23:54:08 +0300
commit68a4c98f5074bd34f0178f2f967153c8d5c71237 (patch)
tree34ecc0cb78dfd4c80a181aece464689ae75b7dbb /app/models/project_wiki.rb
parent41b8d22631053e66043d05695d65f4961b91efd8 (diff)
Cache output of Repository#exists?
This caches the output of Repository#exists? in Redis while making sure it's flushed properly when creating new repositories, deleting them, etc. For the ProjectWiki tests to work I had to make ProjectWiki#create_repo! public as testing private methods in RSpec is a bit of a pain.
Diffstat (limited to 'app/models/project_wiki.rb')
-rw-r--r--app/models/project_wiki.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index 59b1b86d1fb..7c1a61bb0bf 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -123,23 +123,27 @@ class ProjectWiki
end
def repository
- Repository.new(path_with_namespace, @project)
+ @repository ||= Repository.new(path_with_namespace, @project)
end
def default_branch
wiki.class.default_ref
end
- private
-
def create_repo!
if init_repo(path_with_namespace)
- Gollum::Wiki.new(path_to_repo)
+ wiki = Gollum::Wiki.new(path_to_repo)
else
raise CouldNotCreateWikiError
end
+
+ repository.after_create
+
+ wiki
end
+ private
+
def init_repo(path_with_namespace)
gitlab_shell.add_repository(path_with_namespace)
end