2017-10-25 19:35:46 -04:00
|
|
|
#!ruby -an
|
|
|
|
BEGIN {
|
|
|
|
require 'fileutils'
|
2017-10-21 05:50:36 -04:00
|
|
|
|
2017-10-25 19:35:46 -04:00
|
|
|
dir = ARGV.shift
|
|
|
|
ARGF.eof?
|
|
|
|
FileUtils.mkdir_p(dir)
|
|
|
|
Dir.chdir(dir)
|
|
|
|
}
|
2017-10-21 05:50:36 -04:00
|
|
|
|
2020-10-09 05:41:20 -04:00
|
|
|
n, v, u, r = $F
|
|
|
|
|
|
|
|
next if n =~ /^#/
|
2017-10-21 05:50:36 -04:00
|
|
|
|
2017-10-25 19:35:46 -04:00
|
|
|
if File.directory?(n)
|
|
|
|
puts "updating #{n} ..."
|
2020-10-09 05:41:20 -04:00
|
|
|
system("git", "fetch", chdir: n) or abort
|
2017-10-25 19:35:46 -04:00
|
|
|
else
|
|
|
|
puts "retrieving #{n} ..."
|
|
|
|
system(*%W"git clone #{u} #{n}") or abort
|
2017-10-21 05:50:36 -04:00
|
|
|
end
|
2020-10-09 05:41:20 -04:00
|
|
|
c = r || "v#{v}"
|
2020-04-25 00:56:24 -04:00
|
|
|
checkout = %w"git -c advice.detachedHead=false checkout"
|
2020-10-09 05:41:20 -04:00
|
|
|
puts "checking out #{c} (v=#{v}, r=#{r}) ..."
|
|
|
|
unless system(*checkout, c, "--", chdir: n)
|
|
|
|
abort
|
2020-02-23 22:32:50 -05:00
|
|
|
end
|