blob: 4ba1848d00604a016f4e7041440b052067441569 (
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
|
#!ruby -an
BEGIN {
require 'fileutils'
dir = ARGV.shift
ARGF.eof?
FileUtils.mkdir_p(dir)
Dir.chdir(dir)
}
n, v, u = $F
if File.directory?(n)
puts "updating #{n} ..."
system("git", (v == "master" ? "pull" : "fetch"), chdir: n) or abort
else
puts "retrieving #{n} ..."
system(*%W"git clone #{u} #{n}") or abort
end
checkout = %w"git -c advice.detachedHead=false checkout"
unless system(*checkout, v.sub(/\A(?=\d)/, 'v'), chdir: n)
unless /\A\d/ =~ v and system(*checkout, v, chdir: n)
abort
end
end
|