diff mbox series

[bug#45984,5/5] scripts: import: gem: Fix recursive error handling.

Message ID 20210119154721.11999-5-zimon.toutoune@gmail.com
State New
Headers show
Series [bug#45984,1/5] import: pypi: Return 'values'. | expand

Checks

Context Check Description
cbaines/submitting builds success
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

zimoun Jan. 19, 2021, 3:47 p.m. UTC
Fixes partially <https://bugs.gnu.org/44115>.

* guix/scripts/import/gem.scm (guix-import-gem): Handle error.
---
 guix/scripts/import/gem.scm | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/guix/scripts/import/gem.scm b/guix/scripts/import/gem.scm
index c64596b514..99a2955e4c 100644
--- a/guix/scripts/import/gem.scm
+++ b/guix/scripts/import/gem.scm
@@ -1,6 +1,7 @@ 
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
 ;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
+;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -88,18 +89,20 @@  Import and convert the RubyGems package for PACKAGE-NAME.\n"))
                            (reverse opts))))
     (match args
       ((package-name)
-       (if (assoc-ref opts 'recursive)
-           (map (match-lambda
-                  ((and ('package ('name name) . rest) pkg)
-                   `(define-public ,(string->symbol name)
-                      ,pkg))
-                  (_ #f))
-                (gem-recursive-import package-name 'rubygems))
-           (let ((sexp (gem->guix-package package-name)))
-             (unless sexp
-               (leave (G_ "failed to download meta-data for package '~a'~%")
-                      package-name))
-             sexp)))
+       (let ((code (if (assoc-ref opts 'recursive)
+                      (map (match-lambda
+                             ((and ('package ('name name) . rest) pkg)
+                              `(define-public ,(string->symbol name)
+                                 ,pkg))
+                             (_ #f))
+                           (gem-recursive-import package-name 'rubygems))
+                      (let ((sexp (gem->guix-package package-name)))
+                        (if sexp sexp #f)))))
+         (match code
+           ((or #f '(#f))
+            (leave (G_ "failed to download meta-data for package '~a'~%")
+                  package-name))
+           (_ code))))
       (()
        (leave (G_ "too few arguments~%")))
       ((many ...)