From 5721c8263b4ca40e6d0dc31a23be9715fb5b04fa Mon Sep 17 00:00:00 2001 From: Puck Meerburg Date: Sun, 2 Mar 2025 14:10:06 +0000 Subject: [PATCH] (zilch lang rust registry): skip `git fetch` if revspec already fetched --- lang/rust/src/registry.sld | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lang/rust/src/registry.sld b/lang/rust/src/registry.sld index 77a657b..5275a93 100644 --- a/lang/rust/src/registry.sld +++ b/lang/rust/src/registry.sld @@ -127,7 +127,9 @@ (create-directory repo #t) (let-values (((_ _ _) (process-wait (process-run "git" (list "init" "--bare" repo))))) #f)) - (define-values (_ _ _) (process-wait (process-run "git" (list "-C" repo "fetch" "--write-fetch-head" url refspec)))) + (define-values (_ commit-exists _) (process-wait (process-run "git" (list "-C" repo "cat-file" "-e" refspec)))) + (unless commit-exists + (let-values (((_ _ _) (process-wait (process-run "git" (list "-C" repo "fetch" "--write-fetch-head" url refspec))))) #f)) (define tree (read-git-tree repo (string-append refspec ":"))) (define subdir (find-matching-cargo tree name)) (unless subdir (error "could not find package in git repo" (list url refspec name)))