diff options
author | Fatih Acet <acetfatih@gmail.com> | 2016-06-06 18:58:24 +0300 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2016-06-06 18:58:24 +0300 |
commit | 3f2db9d971dd92b446e2a615ed758090079a8c64 (patch) | |
tree | c3034fc5bde8c3d0d2516de01e67d44c0c796fa1 /app/models/project.rb | |
parent | 5b43eeee97f8e06a4ada4b173cb972c20d58d8ed (diff) | |
parent | ac4e3e8cf016f2c2b3dcf3997673310a5df658a9 (diff) | |
download | gitlab-ce-button-focus-state.tar.gz |
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into button-focus-statebutton-focus-state
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index c1d9bae44c9..e4a9d17a20c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -309,21 +309,25 @@ class Project < ActiveRecord::Base @repository ||= Repository.new(path_with_namespace, self) end + def container_registry_path_with_namespace + path_with_namespace.downcase + end + def container_registry_repository return unless Gitlab.config.registry.enabled @container_registry_repository ||= begin - token = Auth::ContainerRegistryAuthenticationService.full_access_token(path_with_namespace) + token = Auth::ContainerRegistryAuthenticationService.full_access_token(container_registry_path_with_namespace) url = Gitlab.config.registry.api_url host_port = Gitlab.config.registry.host_port registry = ContainerRegistry::Registry.new(url, token: token, path: host_port) - registry.repository(path_with_namespace) + registry.repository(container_registry_path_with_namespace) end end def container_registry_repository_url if Gitlab.config.registry.enabled - "#{Gitlab.config.registry.host_port}/#{path_with_namespace}" + "#{Gitlab.config.registry.host_port}/#{container_registry_path_with_namespace}" end end @@ -1007,4 +1011,22 @@ class Project < ActiveRecord::Base update_attribute(:pending_delete, true) end + + def running_or_pending_build_count(force: false) + Rails.cache.fetch(['projects', id, 'running_or_pending_build_count'], force: force) do + builds.running_or_pending.count(:all) + end + end + + def mark_import_as_failed(error_message) + original_errors = errors.dup + sanitized_message = Gitlab::UrlSanitizer.sanitize(error_message) + + import_fail + update_column(:import_error, sanitized_message) + rescue ActiveRecord::ActiveRecordError => e + Rails.logger.error("Error setting import status to failed: #{e.message}. Original error: #{sanitized_message}") + ensure + @errors = original_errors + end end |