Fetch only necessary commits of bundled gems

This commit is contained in:
Nobuyoshi Nakada 2025-06-08 21:27:19 +09:00
parent 3b17ff2457
commit 698cf146ac
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2025-06-09 15:45:35 +00:00
2 changed files with 9 additions and 7 deletions

View File

@ -365,7 +365,7 @@ $(srcdir)/.bundle/.timestamp:
define build-gem
$(srcdir)/gems/src/$(1)/.git: | $(srcdir)/gems/src
$(ECHO) Cloning $(4)
$(Q) $(GIT) clone $(4) $$(@D)
$(Q) $(GIT) clone --depth=1 --no-tags $(4) $$(@D)
$(bundled-gem-revision): \
$(if $(if $(wildcard $$(@)),$(filter $(3),$(shell cat $$(@)))),,PHONY) \

View File

@ -24,20 +24,22 @@ next unless n
next if n =~ /^#/
next if bundled_gems&.all? {|pat| !File.fnmatch?(pat, n)}
if File.directory?(n)
puts "updating #{color.notice(n)} ..."
system("git", "fetch", "--all", chdir: n) or abort
else
unless File.exist?("#{n}/.git")
puts "retrieving #{color.notice(n)} ..."
system(*%W"git clone #{u} #{n}") or abort
system(*%W"git clone --depth=1 --no-tags #{u} #{n}") or abort
end
if r
puts "fetching #{color.notice(r)} ..."
system("git", "fetch", "origin", r, chdir: n) or abort
c = r
else
c = ["v#{v}", v].find do |c|
puts "fetching #{color.notice(c)} ..."
system("git", "fetch", "origin", "refs/tags/#{c}:refs/tags/#{c}", chdir: n)
end or abort
end
c = r || "v#{v}"
checkout = %w"git -c advice.detachedHead=false checkout"
print %[checking out #{color.notice(c)} (v=#{color.info(v)}]
print %[, r=#{color.info(r)}] if r