summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-02-18 12:19:49 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2016-02-18 12:19:49 +0100
commit54aa0969d40549014bee6e4e500276405fb055ee (patch)
tree0c68490b649cd4bb9274ef6933c5c3fee86959f8 /app
parentc475b171114e9bd49b2f1779eb91d392328928d8 (diff)
downloadgitlab-ce-54aa0969d40549014bee6e4e500276405fb055ee.tar.gz
Fixed Repository#exists? to handle errors
Now that Repository#raw_repository no longer sets the autocrlf option it will also no longer raise any NoRepository errors since it doesn't access Rugged any more. This also means that Repository#exists? can't simply return the raw repository as this is no indication of whether or not the repository actually exists (besides returning a non boolean is weird in the first place). To solve this problem Repository#exists? now properly checks if the repository exists and returns true/false instead of a Gitlab::Git::Repository or nil object.
Diffstat (limited to 'app')
-rw-r--r--app/models/repository.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 381b1db3758..631a248258f 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -23,11 +23,7 @@ class Repository
def raw_repository
return nil unless path_with_namespace
- @raw_repository ||= begin
- Gitlab::Git::Repository.new(path_to_repo)
- rescue Gitlab::Git::Repository::NoRepository
- nil
- end
+ @raw_repository ||= Gitlab::Git::Repository.new(path_to_repo)
end
def update_autocrlf_option
@@ -42,7 +38,10 @@ class Repository
end
def exists?
- raw_repository
+ raw_repository.rugged
+ true
+ rescue Gitlab::Git::Repository::NoRepository
+ false
end
def empty?