2017-10-26 02:35:46 +03:00
|
|
|
#!ruby -an
|
|
|
|
BEGIN {
|
|
|
|
require 'fileutils'
|
2024-03-02 18:39:09 +03:00
|
|
|
require_relative 'lib/colorize'
|
|
|
|
|
|
|
|
color = Colorize.new
|
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)
|
2024-03-02 18:39:09 +03:00
|
|
|
puts "updating #{color.notice(n)} ..."
|
2023-12-27 04:14:34 +03:00
|
|
|
system("git", "fetch", "--all", chdir: n) or abort
|
2017-10-26 02:35:46 +03:00
|
|
|
else
|
2024-03-02 18:39:09 +03:00
|
|
|
puts "retrieving #{color.notice(n)} ..."
|
2017-10-26 02:35:46 +03:00
|
|
|
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
|
2024-03-02 18:39:09 +03:00
|
|
|
puts "fetching #{color.notice(r)} ..."
|
2022-01-01 13:18:03 +03:00
|
|
|
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"
|
2024-03-02 18:39:09 +03:00
|
|
|
print %[checking out #{color.notice(c)} (v=#{color.info(v)}]
|
|
|
|
print %[, r=#{color.info(r)}] if r
|
|
|
|
puts ") ..."
|
2023-04-26 11:22:03 +03:00
|
|
|
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
|