Class: MilkTea::UpstreamSources::Source
- Inherits:
-
Data
- Object
- Data
- MilkTea::UpstreamSources::Source
- Defined in:
- lib/milk_tea/bindings/upstream_sources.rb
Instance Attribute Summary collapse
-
#checkout_root ⇒ Object
readonly
Returns the value of attribute checkout_root.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#repository_url ⇒ Object
readonly
Returns the value of attribute repository_url.
-
#revision ⇒ Object
readonly
Returns the value of attribute revision.
-
#sentinel_paths ⇒ Object
readonly
Returns the value of attribute sentinel_paths.
Instance Method Summary collapse
Instance Attribute Details
#checkout_root ⇒ Object (readonly)
Returns the value of attribute checkout_root
16 17 18 |
# File 'lib/milk_tea/bindings/upstream_sources.rb', line 16 def checkout_root @checkout_root end |
#name ⇒ Object (readonly)
Returns the value of attribute name
16 17 18 |
# File 'lib/milk_tea/bindings/upstream_sources.rb', line 16 def name @name end |
#repository_url ⇒ Object (readonly)
Returns the value of attribute repository_url
16 17 18 |
# File 'lib/milk_tea/bindings/upstream_sources.rb', line 16 def repository_url @repository_url end |
#revision ⇒ Object (readonly)
Returns the value of attribute revision
16 17 18 |
# File 'lib/milk_tea/bindings/upstream_sources.rb', line 16 def revision @revision end |
#sentinel_paths ⇒ Object (readonly)
Returns the value of attribute sentinel_paths
16 17 18 |
# File 'lib/milk_tea/bindings/upstream_sources.rb', line 16 def sentinel_paths @sentinel_paths end |
Instance Method Details
#bootstrap! ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/milk_tea/bindings/upstream_sources.rb', line 17 def bootstrap! return Result.new(source: self, status: :present, path: checkout_root.to_s) if complete? FileUtils.rm_rf(checkout_root) if File.exist?(checkout_root) FileUtils.mkdir_p(checkout_root.dirname) run_git!("clone", repository_url, checkout_root.to_s) run_git!("-C", checkout_root.to_s, "checkout", "--detach", revision) unless complete? raise Error, "bootstrapped #{name} but required files are still missing under #{checkout_root}" end Result.new(source: self, status: :bootstrapped, path: checkout_root.to_s) end |
#complete? ⇒ Boolean
33 34 35 36 37 38 39 |
# File 'lib/milk_tea/bindings/upstream_sources.rb', line 33 def complete? return false unless File.directory?(checkout_root) sentinel_paths.all? do |relative_path| File.exist?(checkout_root.join(relative_path)) end end |