lib/librarian/puppet/source/githubtarball.rb in librarian-puppet-0.9.6 vs lib/librarian/puppet/source/githubtarball.rb in librarian-puppet-0.9.7
- old
+ new
@@ -20,11 +20,12 @@
data = api_call("/repos/#{source.uri}/tags")
if data.nil?
raise Error, "Unable to find module '#{source.uri}' on https://github.com"
end
- data.map { |r| r['name'] }.sort.reverse
+ all_versions = data.map { |r| r['name'] }.sort.reverse
+ all_versions.reject { |version| version =~ /^v/ }.compact
end
def manifests
versions.map do |version|
Manifest.new(source, name, version)
@@ -83,12 +84,20 @@
environment.vendor_cache.mkpath
environment.vendor_cache.join("#{name.sub("/", "-")}-#{version}.tar.gz")
end
def vendor_cache(name, version)
+ clean_up_old_cached_versions(name)
+
url = "https://api.github.com/repos/#{name}/tarball/#{version}"
url << "?access_token=#{ENV['GITHUB_API_TOKEN']}" if ENV['GITHUB_API_TOKEN']
`curl #{url} -o #{vendored_path(name, version).to_s} -L 2>&1`
+ end
+
+ def clean_up_old_cached_versions(name)
+ Dir["#{environment.vendor_cache}/#{name.sub('/', '-')}*.tar.gz"].each do |old_version|
+ FileUtils.rm old_version
+ end
end
private
def api_call(path)