From 2c796a1785242a6940ef3b7ef8a06fa8617ec245 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 21 Mar 2015 13:44:11 -0700 Subject: [PATCH] Cache project branches and tags into variables --- CHANGELOG | 1 + app/models/repository.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 4c644960088..e547085043d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ v 7.10.0 (unreleased) - Improve error message when save profile has error. - Passing the name of pushed ref to CI service (requires GitLab CI 7.9+) - Add location field to user profile + - Improve GitLab performance when working with git repositories v 7.9.0 (unreleased) - Add HipChat integration documentation (Stan Hu) diff --git a/app/models/repository.rb b/app/models/repository.rb index c6eaa485b8a..2e3cfb85594 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -62,24 +62,28 @@ class Repository def add_branch(branch_name, ref) cache.expire(:branch_names) + @branches = nil gitlab_shell.add_branch(path_with_namespace, branch_name, ref) end def add_tag(tag_name, ref, message = nil) cache.expire(:tag_names) + @tags = nil gitlab_shell.add_tag(path_with_namespace, tag_name, ref, message) end def rm_branch(branch_name) cache.expire(:branch_names) + @branches = nil gitlab_shell.rm_branch(path_with_namespace, branch_name) end def rm_tag(tag_name) cache.expire(:tag_names) + @tags = nil gitlab_shell.rm_tag(path_with_namespace, tag_name) end @@ -368,6 +372,18 @@ class Repository end end + def branches + @branches ||= raw_repository.branches + end + + def tags + @tags ||= raw_repository.tags + end + + def root_ref + @root_ref ||= raw_repository.root_ref + end + private def cache