Class: Ci::PersistentRef
- Inherits:
- 
      Object
      
        - Object
- Ci::PersistentRef
 
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/ci/persistent_ref.rb
Overview
The persistent pipeline ref to ensure runners can safely fetch source code even if force-push/source-branch-deletion happens.
Instance Attribute Summary collapse
- 
  
    
      #pipeline  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute pipeline. 
Instance Method Summary collapse
- #async_delete ⇒ Object
- #create ⇒ Object
- #delete ⇒ Object
- #exist? ⇒ Boolean
- #path ⇒ Object
- 
  
    
      #should_delete?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    This needs to be kept in sync with ‘Ci::Pipeline#after_transition` calling `pipeline.persistent_ref.delete`. 
Instance Attribute Details
#pipeline ⇒ Object
Returns the value of attribute pipeline.
| 10 11 12 | # File 'app/models/ci/persistent_ref.rb', line 10 def pipeline @pipeline end | 
Instance Method Details
#async_delete ⇒ Object
| 46 47 48 49 50 | # File 'app/models/ci/persistent_ref.rb', line 46 def async_delete return unless should_delete? async_delete_refs(path) end | 
#create ⇒ Object
| 27 28 29 30 31 32 33 | # File 'app/models/ci/persistent_ref.rb', line 27 def create create_ref(sha, path) rescue StandardError => e Gitlab::ErrorTracking .track_exception(e, pipeline_id: pipeline.id) false end | 
#delete ⇒ Object
| 35 36 37 38 39 40 41 42 43 44 | # File 'app/models/ci/persistent_ref.rb', line 35 def delete return unless should_delete? delete_refs(path) rescue Gitlab::Git::Repository::NoRepository # no-op rescue StandardError => e Gitlab::ErrorTracking .track_exception(e, pipeline_id: pipeline.id) end | 
#exist? ⇒ Boolean
| 16 17 18 19 20 | # File 'app/models/ci/persistent_ref.rb', line 16 def exist? ref_exists?(path) rescue StandardError false end | 
#path ⇒ Object
| 52 53 54 | # File 'app/models/ci/persistent_ref.rb', line 52 def path "refs/#{Repository::REF_PIPELINES}/#{pipeline.id}" end |