guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#63647] [PATCH v2 2/3] guix: import: go: Catch Git error.


From: Simon Tournier
Subject: [bug#63647] [PATCH v2 2/3] guix: import: go: Catch Git error.
Date: Thu, 25 May 2023 17:41:11 +0200

* guix/import/go.scm (git-checkout-hash): Catch Git error.

Reported-by: Felix Lechner <felix.lechner@lease-up.com>.
---
 guix/import/go.scm | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/guix/import/go.scm b/guix/import/go.scm
index 1943869162..c6258296f6 100644
--- a/guix/import/go.scm
+++ b/guix/import/go.scm
@@ -6,7 +6,7 @@
 ;;; Copyright © 2021-2022 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
 ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
-;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2021, 2023 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -36,9 +36,11 @@ (define-module (guix import go)
   #:use-module (guix memoization)
   #:use-module (guix utils)
   #: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)
+  #:autoload   (git structs) (git-error-message)
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:use-module (ice-9 peg)
@@ -507,12 +509,18 @@ (define* (git-checkout-hash url reference algorithm)
   ;; subsequent "guix import" invocations.
   (mkdir-p cache)
   (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 _
+      (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)))
+    (lambda (key error . rest)
+      (warning (G_ "Git error: ~a in ~a~%") (git-error-message error) url)
+      (nix-base32-string->bytevector
+       "0000000000000000000000000000000000000000000000000000"))))
 
 (define (vcs->origin vcs-type vcs-repo-url version)
   "Generate the `origin' block of a package depending on what type of source
-- 
2.38.1






reply via email to

[Prev in Thread] Current Thread [Next in Thread]