diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-14 19:24:15 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-19 12:13:18 +0300 |
commit | 6385b49572542066d3eb5c197ba0208bfa3158fb (patch) | |
tree | 807b6c91bcbf350f393619fbd940950e6490acee /app/models/repository.rb | |
parent | 2c00d00ec1c39dbea0e0e54265027b5476b78e3c (diff) |
Forbid repository access when in lock
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r-- | app/models/repository.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 72e473871fa..c4bd6d303dc 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -11,6 +11,14 @@ class Repository attr_accessor :path_with_namespace, :project + def self.with_forbidden_access + @@forbidden_access ||= 0 + @@forbidden_access += 1 + yield + rescue + @@forbidden_access -= 1 + end + def initialize(path_with_namespace, project) @path_with_namespace = path_with_namespace @project = project @@ -19,6 +27,8 @@ class Repository def raw_repository return nil unless path_with_namespace + raise 'Repository access is forbidden' if @@forbidden_access + @raw_repository ||= Gitlab::Git::Repository.new(path_to_repo) end |