GNU bug report logs - #74481
[PATCH 0/2] Handle corner cases of 'guix import go'

Previous Next

Package: guix-patches;

Reported by: Simon Tournier <zimon.toutoune <at> gmail.com>

Date: Fri, 22 Nov 2024 19:07:02 UTC

Severity: normal

Tags: patch

Done: Simon Tournier <zimon.toutoune <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #29 received at 74481 <at> debbugs.gnu.org (full text, mbox):

From: Simon Tournier <zimon.toutoune <at> gmail.com>
To: 74481 <at> debbugs.gnu.org
Cc: Simon Tournier <zimon.toutoune <at> gmail.com>
Subject: [PATCH v2] import: go: Warn instead of error out when Git fails.
Date: Tue, 17 Dec 2024 18:45:02 +0100
* guix/import/go.scm (git-checkout-hash): Return some hash although updating
the cache fails.

Change-Id: I87e7701023a5f76f5d1494827473616e6a1275aa
---
 guix/import/go.scm | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/guix/import/go.scm b/guix/import/go.scm
index 32cba25b33..6ede152601 100644
--- a/guix/import/go.scm
+++ b/guix/import/go.scm
@@ -38,7 +38,8 @@ (define-module (guix import go)
   #:use-module (guix http-client)
   #:use-module (guix memoization)
   #:autoload   (htmlprag) (html->sxml)            ;from Guile-Lib
-  #:autoload   (guix base32) (bytevector->nix-base32-string)
+  #:autoload   (guix base32) (bytevector->nix-base32-string
+                              nix-base32-string->bytevector)
   #:autoload   (guix build utils) (mkdir-p)
   #:autoload   (guix ui) (warning)
   #:autoload   (gcrypt hash) (hash-algorithm sha256)
@@ -563,10 +564,18 @@ (define* (git-checkout-hash url reference algorithm)
   (chmod cache #o700)
   (let-values (((checkout commit _)
                 (parameterize ((%repository-cache-directory cache))
-                  (update-cached-checkout url
-                                          #:ref
-                                          `(tag-or-commit . ,reference)))))
-    (file-hash* checkout #:algorithm algorithm #:recursive? #true)))
+                  (catch 'git-error
+                    (lambda ()
+                      (update-cached-checkout url
+                                              #:ref
+                                              `(tag-or-commit . ,reference)))
+                    (lambda (key err)
+                      (warning (G_ "update-cached-checkout: ~s ~s~%") key err)
+                      (values #f #f #f))))))
+        (if (and checkout commit)
+            (file-hash* checkout #:algorithm algorithm #:recursive? #true)
+            (nix-base32-string->bytevector
+             "0000000000000000000000000000000000000000000000000000"))))
 
 (define (vcs->origin vcs-type vcs-repo-url version subdir)
   "Generate the `origin' block of a package depending on what type of source

base-commit: a9003b8e6b40b59c9545ae87bb441d3549630db7
-- 
2.45.2





This bug report was last modified 132 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.