Class: Repositories::BaseService
- Inherits:
-
BaseService
- Object
- BaseService
- Repositories::BaseService
- Includes:
- Gitlab::ShellAdapter
- Defined in:
- app/services/repositories/base_service.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
-
#ignore_git_errors(&block) ⇒ Object
If we get a Gitaly error, the repository may be corrupted.
-
#initialize(repository) ⇒ BaseService
constructor
A new instance of BaseService.
- #move_error(path) ⇒ Object
- #mv_repository(from_path, to_path) ⇒ Object
- #repo_exists?(path) ⇒ Boolean
Methods included from Gitlab::ShellAdapter
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Constructor Details
#initialize(repository) ⇒ BaseService
Returns a new instance of BaseService.
10 11 12 |
# File 'app/services/repositories/base_service.rb', line 10 def initialize(repository) @repository = repository end |
Instance Attribute Details
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
6 7 8 |
# File 'app/services/repositories/base_service.rb', line 6 def repository @repository end |
Instance Method Details
#ignore_git_errors(&block) ⇒ Object
If we get a Gitaly error, the repository may be corrupted. We can ignore these errors since we’re going to trash the repositories anyway.
25 26 27 28 29 |
# File 'app/services/repositories/base_service.rb', line 25 def ignore_git_errors(&block) yield rescue Gitlab::Git::CommandError => e Gitlab::GitLogger.warn(class: self.class.name, container_id: container.id, disk_path: disk_path, message: e.to_s) end |
#move_error(path) ⇒ Object
31 32 33 34 35 36 |
# File 'app/services/repositories/base_service.rb', line 31 def move_error(path) error = %(Repository "#{path}" could not be moved) log_error(error) error(error) end |
#mv_repository(from_path, to_path) ⇒ Object
18 19 20 |
# File 'app/services/repositories/base_service.rb', line 18 def mv_repository(from_path, to_path) gitlab_shell.mv_repository(repository.shard, from_path, to_path) end |
#repo_exists?(path) ⇒ Boolean
14 15 16 |
# File 'app/services/repositories/base_service.rb', line 14 def repo_exists?(path) gitlab_shell.repository_exists?(repository.shard, path + '.git') end |