Class: Librarian::Puppet::Source::Git

Inherits:
Source::Git show all
Includes:
Local
Defined in:
lib/librarian/puppet/source/git.rb

Instance Method Summary collapse

Methods included from Local

#install!

Methods inherited from Source::Git

#hash

Instance Method Details

#cache!Object



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/librarian/puppet/source/git.rb', line 71

def cache!
  return vendor_checkout! if vendor_cached?

  if environment.local?
    raise Error, "Could not find a local copy of #{uri} at #{sha}."
  end

  super

  cache_in_vendor(repository.path) if environment.vendor?
end

#cache_in_vendor(tmp_path) ⇒ Object



102
103
104
105
106
# File 'lib/librarian/puppet/source/git.rb', line 102

def cache_in_vendor(tmp_path)
  Dir.chdir(tmp_path.to_s) do
    %x{git archive #{sha} | gzip > #{vendor_tgz}}
  end
end

#fetch_dependencies(name, version, extra) ⇒ Object



122
123
124
# File 'lib/librarian/puppet/source/git.rb', line 122

def fetch_dependencies(name, version, extra)
  repository.dependencies
end

#fetch_version(name, extra) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/librarian/puppet/source/git.rb', line 108

def fetch_version(name, extra)
  cache!
  found_path = found_path(name)
  v = repository.module_version
  v = v.gsub("-",".") # fix for some invalid versions like 1.0.0-rc1

  # if still not valid, use some default version
  unless Gem::Version.correct? v
    debug { "Ignoring invalid version '#{v}' for module #{name}, using 0.0.1" }
    v = '0.0.1'
  end
  v
end

#vendor_cached?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/librarian/puppet/source/git.rb', line 87

def vendor_cached?
  vendor_tgz.exist?
end

#vendor_checkout!Object



91
92
93
94
95
96
97
98
99
100
# File 'lib/librarian/puppet/source/git.rb', line 91

def vendor_checkout!
  repository.path.rmtree if repository.path.exist?
  repository.path.mkpath

  Dir.chdir(repository.path.to_s) do
    %x{tar xzf #{vendor_tgz}}
  end

  repository_cached!
end

#vendor_tgzObject



83
84
85
# File 'lib/librarian/puppet/source/git.rb', line 83

def vendor_tgz
  environment.vendor_source + "#{sha}.tar.gz"
end