summaryrefslogtreecommitdiff
path: root/app/models/repository.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r--app/models/repository.rb17
1 files changed, 7 insertions, 10 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 6b2383b73eb..dc1c1fab880 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -59,7 +59,7 @@ class Repository
def raw_repository
return nil unless path_with_namespace
- @raw_repository ||= Gitlab::Git::Repository.new(path_to_repo)
+ @raw_repository ||= initialize_raw_repository
end
# Return absolute path to repository
@@ -146,12 +146,7 @@ class Repository
# may cause the branch to "disappear" erroneously or have the wrong SHA.
#
# See: https://github.com/libgit2/libgit2/issues/1534 and https://gitlab.com/gitlab-org/gitlab-ce/issues/15392
- raw_repo =
- if fresh_repo
- Gitlab::Git::Repository.new(path_to_repo)
- else
- raw_repository
- end
+ raw_repo = fresh_repo ? initialize_raw_repository : raw_repository
raw_repo.find_branch(name)
end
@@ -505,9 +500,7 @@ class Repository
end
end
- def branch_names
- branches.map(&:name)
- end
+ delegate :branch_names, to: :raw_repository
cache_method :branch_names, fallback: []
delegate :tag_names, to: :raw_repository
@@ -1168,4 +1161,8 @@ class Repository
def repository_storage_path
@project.repository_storage_path
end
+
+ def initialize_raw_repository
+ Gitlab::Git::Repository.new(project.repository_storage, path_with_namespace + '.git')
+ end
end