diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-19 12:46:06 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-19 12:46:06 +0300 |
commit | ee890c26552fbeabbd9ffeb55a4bc6e8b007f7bf (patch) | |
tree | 8b9306edf43976d68d05c087e70afb48f33ff7fd /app/models/repository.rb | |
parent | c5f5e25af2230a20a19b7024e868ece7bb5e5105 (diff) |
Fix after code review
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r-- | app/models/repository.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index f9ba28c1d4d..b6cd925e878 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -2,6 +2,7 @@ require 'securerandom' class Repository class CommitError < StandardError; end + class AccessForbiddenError < StandardError; end # Files to use as a project avatar in case no avatar was uploaded via the web # UI. @@ -19,6 +20,10 @@ class Repository Thread.current[:repository_forbidden_access] -= 1 end + def self.is_access_forbidden? + Thread.current[:repository_forbidden_access].to_i > 0 + end + def initialize(path_with_namespace, project) @path_with_namespace = path_with_namespace @project = project @@ -27,7 +32,7 @@ class Repository def raw_repository return nil unless path_with_namespace - raise 'Repository access is forbidden' if Thread.current[:repository_forbidden_access].to_i > 0 + raise AccessForbiddenError.new('Repository access is forbidden') if Repository.is_access_forbidden? @raw_repository ||= Gitlab::Git::Repository.new(path_to_repo) end |