ruby/tool/update-bundled_gems.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 строки
1.1 KiB
Ruby
Исходник Обычный вид История

#!ruby -pla
BEGIN {
require 'rubygems'
date = nil
# STDOUT is not usable in inplace edit mode
output = $-i ? STDOUT : STDERR
}
output = STDERR if ARGF.file == STDIN
END {
output.print date.strftime("latest_date=%F") if date
}
unless /^[^#]/ !~ (gem = $F[0])
2023-11-04 05:29:42 +03:00
ver = Gem::Version.new($F[1])
(gem, src), = Gem::SpecFetcher.fetcher.detect(:latest) {|s|
s.platform == "ruby" && s.name == gem
}
2023-11-04 05:29:42 +03:00
if gem.version > ver
gem = src.fetch_spec(gem)
if ENV["UPDATE_BUNDLED_GEMS_ALL"]
uri = gem.metadata["source_code_uri"] || gem.homepage
uri = uri.sub(%r[\Ahttps://github\.com/[^/]+/[^/]+\K/tree/.*], "").chomp(".git")
else
uri = $F[2]
end
date = gem.date if !date or gem.date && gem.date > date
if $F[3]
if $F[3].include?($F[1])
$F[3][$F[1]] = gem.version.to_s
elsif Gem::Version.new($F[1]) != gem.version and /\A\h+\z/ =~ $F[3]
$F[3..-1] = []
end
2021-07-21 14:44:13 +03:00
end
2023-11-04 05:29:42 +03:00
f = [gem.name, gem.version.to_s, uri, *$F[3..-1]]
$_.gsub!(/\S+\s*(?=\s|$)/) {|s| (f.shift || "").ljust(s.size)}
$_ = [$_, *f].join(" ") unless f.empty?
$_.rstrip!
2021-07-21 14:44:13 +03:00
end
end