Class: Gitlab::Git::KeepAround
- Inherits:
-
Object
- Object
- Gitlab::Git::KeepAround
- Defined in:
- lib/gitlab/git/keep_around.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute(shas) ⇒ Object
-
#initialize(repository) ⇒ KeepAround
constructor
A new instance of KeepAround.
- #kept_around?(sha) ⇒ Boolean
Constructor Details
#initialize(repository) ⇒ KeepAround
Returns a new instance of KeepAround.
17 18 19 |
# File 'lib/gitlab/git/keep_around.rb', line 17 def initialize(repository) @repository = repository end |
Class Method Details
.execute(repository, shas) ⇒ Object
13 14 15 |
# File 'lib/gitlab/git/keep_around.rb', line 13 def self.execute(repository, shas) new(repository).execute(shas) end |
Instance Method Details
#execute(shas) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/gitlab/git/keep_around.rb', line 21 def execute(shas) return if disabled? shas.uniq.each do |sha| next unless sha.present? && commit_by(oid: sha) next if kept_around?(sha) # This will still fail if the file is corrupted (e.g. 0 bytes) raw_repository.write_ref(keep_around_ref_name(sha), sha) rescue Gitlab::Git::CommandError => ex Gitlab::AppLogger.error "Unable to create keep-around reference for repository #{disk_path}: #{ex}" end end |
#kept_around?(sha) ⇒ Boolean
36 37 38 39 40 |
# File 'lib/gitlab/git/keep_around.rb', line 36 def kept_around?(sha) return true if disabled? ref_exists?(keep_around_ref_name(sha)) end |