Skip fetching bundled gems whose ref is already present

With a warm gems/src cache the wanted tag or revision is already in the local clone, but the fetch ran unconditionally and added a github.com round-trip per gem that a transient outage could abort. Resolve the ref locally first and fetch only when it is missing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hiroshi SHIBATAandClaude Opus 4.8 committed 2026-06-22 17:44:03 +09:00
1 parent 7c8668d955
commit fa69b96be2
1 file changed
+9 -1
Notes: git 2026-06-22 08:44:34 +00:00
+9 -1
View File
@@ -28,7 +28,15 @@ unless File.exist?("#{n}/.git")
system(*%W"git clone --depth=1 --no-tags #{u} #{n}") or abort
end
c = (r ? [r] : ["v#{v}", v]).find do |c|
candidates = r ? [r] : ["v#{v}", v]
# Skip fetching from the remote when the target ref already exists locally
# (e.g. restored from cache), so a transient network failure does not abort.
c = candidates.find do |c|
system("git", "rev-parse", "-q", "--verify", "#{c}^{commit}", out: File::NULL, err: File::NULL, chdir: n)
end
c ||= candidates.find do |c|
puts "fetching #{n} #{color.notice(c)} ..."
system("git", "fetch", "origin", r || "refs/tags/#{c}:refs/tags/#{c}", chdir: n)
end or abort