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
|
|
|
|
2017-10-25 19:35:46 -04:00
|
|
|
n, v, u = $F
|
2017-10-21 05:50:36 -04:00
|
|
|
|
2017-10-25 19:35:46 -04:00
|
|
|
if File.directory?(n)
|
|
|
|
puts "updating #{n} ..."
|
2020-02-23 22:40:34 -05:00
|
|
|
system("git", (v == "master" ? "pull" : "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-02-23 22:40:34 -05:00
|
|
|
unless system(*%W"git checkout #{v.sub(/\A(?=\d)/, 'v')}", chdir: n)
|
|
|
|
unless /\A\d/ =~ v and system(*%W"git checkout #{v}", chdir: n)
|
2020-02-23 22:32:50 -05:00
|
|
|
abort
|
|
|
|
end
|
|
|
|
end
|