blob: 90c5fbff37d228de6ec1248abbfa422c6f6433b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!ruby -an
BEGIN {
require 'fileutils'
dir = ARGV.shift
ARGF.eof?
FileUtils.mkdir_p(dir)
Dir.chdir(dir)
}
n, v, u, r = $F
next if n =~ /^#/
if File.directory?(n)
puts "updating #{n} ..."
system("git", "fetch", chdir: n) or abort
else
puts "retrieving #{n} ..."
system(*%W"git clone #{u} #{n}") or abort
end
if r
puts "fetching #{r} ..."
system("git", "fetch", "origin", r, chdir: n) or abort
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
end
|