Commit 54aa0969 authored by Yorick Peterse's avatar Yorick Peterse

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.
parent c475b171
......@@ -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?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment