2017-10-26 02:35:46 +03:00
|
|
|
#!ruby -an
|
|
|
|
BEGIN {
|
|
|
|
require 'fileutils'
|
2017-10-21 12:50:36 +03:00
|
|
|
|
2017-10-26 02:35:46 +03:00
|
|
|
dir = ARGV.shift
|
|
|
|
ARGF.eof?
|
|
|
|
FileUtils.mkdir_p(dir)
|
|
|
|
Dir.chdir(dir)
|
|
|
|
}
|
2017-10-21 12:50:36 +03:00
|
|
|
|
2020-10-09 12:41:20 +03:00
|
|
|
n, v, u, r = $F
|
|
|
|
|
2023-01-10 17:31:04 +03:00
|
|
|
next unless n
|
2020-10-09 12:41:20 +03:00
|
|
|
next if n =~ /^#/
|
2017-10-21 12:50:36 +03:00
|
|
|
|
2017-10-26 02:35:46 +03:00
|
|
|
if File.directory?(n)
|
|
|
|
puts "updating #{n} ..."
|
2020-10-09 12:41:20 +03:00
|
|
|
system("git", "fetch", chdir: n) or abort
|
2017-10-26 02:35:46 +03:00
|
|
|
else
|
|
|
|
puts "retrieving #{n} ..."
|
|
|
|
system(*%W"git clone #{u} #{n}") or abort
|
2017-10-21 12:50:36 +03:00
|
|
|
end
|
2023-04-26 11:22:03 +03:00
|
|
|
|
2022-01-01 13:18:03 +03:00
|
|
|
if r
|
|
|
|
puts "fetching #{r} ..."
|
|
|
|
system("git", "fetch", "origin", r, chdir: n) or abort
|
2023-04-26 11:22:03 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
c = r || "v#{v}"
|
|
|
|
checkout = %w"git -c advice.detachedHead=false checkout"
|
|
|
|
puts "checking out #{c} (v=#{v}, r=#{r}) ..."
|
|
|
|
unless system(*checkout, c, "--", chdir: n)
|
|
|
|
abort if r or !system(*checkout, v, "--", chdir: n)
|
|
|
|
end
|
2023-03-08 09:45:58 +03:00
|
|
|
|
2023-04-26 11:22:03 +03:00
|
|
|
if r
|
2023-03-08 09:45:58 +03:00
|
|
|
unless File.exist? "#{n}/#{n}.gemspec"
|
|
|
|
require_relative "lib/bundled_gem"
|
|
|
|
BundledGem.dummy_gemspec("#{n}/#{n}.gemspec")
|
|
|
|
end
|
2022-01-01 13:18:03 +03:00
|
|
|
end
|