Class: MilkTea::UpstreamSources::Source

Inherits:
Data
  • Object
show all
Defined in:
lib/milk_tea/bindings/upstream_sources.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#checkout_rootObject (readonly)

Returns the value of attribute checkout_root

Returns:

  • (Object)

    the current value of checkout_root



16
17
18
# File 'lib/milk_tea/bindings/upstream_sources.rb', line 16

def checkout_root
  @checkout_root
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



16
17
18
# File 'lib/milk_tea/bindings/upstream_sources.rb', line 16

def name
  @name
end

#repository_urlObject (readonly)

Returns the value of attribute repository_url

Returns:

  • (Object)

    the current value of repository_url



16
17
18
# File 'lib/milk_tea/bindings/upstream_sources.rb', line 16

def repository_url
  @repository_url
end

#revisionObject (readonly)

Returns the value of attribute revision

Returns:

  • (Object)

    the current value of revision



16
17
18
# File 'lib/milk_tea/bindings/upstream_sources.rb', line 16

def revision
  @revision
end

#sentinel_pathsObject (readonly)

Returns the value of attribute sentinel_paths

Returns:

  • (Object)

    the current value of 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

Returns:

  • (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