Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/ci/pipeline.rb16
-rw-r--r--app/models/repository.rb7
2 files changed, 14 insertions, 9 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 89a0c46b4e7..c0b92cf356a 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -265,14 +265,14 @@ module Ci
def update_status
Repository.with_forbidden_access do
with_lock do
- case latest_builds_status
- when 'pending' then enqueue
- when 'running' then run
- when 'success' then succeed
- when 'failed' then drop
- when 'canceled' then cancel
- when 'skipped' then skip
- end
+ case latest_builds_status
+ when 'pending' then enqueue
+ when 'running' then run
+ when 'success' then succeed
+ when 'failed' then drop
+ when 'canceled' then cancel
+ when 'skipped' then skip
+ end
end
end
end
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