GNU bug report logs - #57694
[PATCH 0/1] Support for importing a specified version of a gem.

Previous Next

Package: guix-patches;

Reported by: Taiju HIGASHI <higashi <at> taiju.info>

Date: Fri, 9 Sep 2022 13:46:02 UTC

Severity: normal

Tags: patch

Done: Christopher Baines <mail <at> cbaines.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 57694 in the body.
You can then email your comments to 57694 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#57694; Package guix-patches. (Fri, 09 Sep 2022 13:46:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Taiju HIGASHI <higashi <at> taiju.info>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Fri, 09 Sep 2022 13:46:02 GMT) Full text and rfc822 format available.

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

From: Taiju HIGASHI <higashi <at> taiju.info>
To: guix-patches <at> gnu.org
Cc: Taiju HIGASHI <higashi <at> taiju.info>
Subject: [PATCH 0/1] Support for importing a specified version of a gem.
Date: Fri,  9 Sep 2022 22:44:33 +0900
Hi,

I've improved the guix gem importer. We can import a specific version gem by
this patch.
Hopefully, I'd like to improve gem-recursive-import so that become can import
specific version dependencies.
To do so, we need to implement a parser for the gem version string and a
resolver to fetch the latest gem of the version range. (such as the go
importer)
It may be difficult for me, but I'll try later.
However, this patch is not perfect, but I think that still useful.

I recognize that I should modify the documentation, but I'm not good at
English, so could you modify the documentation if you need it?

Regard,

Taiju HIGASHI (1):
  import: gem: Support for importing a specified version of a gem.

 guix/import/gem.scm         |  19 ++++--
 guix/scripts/import/gem.scm |  39 +++++++------
 tests/gem.scm               | 113 ++++++++++++++++++++++++++++++++++++
 3 files changed, 148 insertions(+), 23 deletions(-)

--
2.37.2




Information forwarded to guix-patches <at> gnu.org:
bug#57694; Package guix-patches. (Fri, 09 Sep 2022 13:49:02 GMT) Full text and rfc822 format available.

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

From: Taiju HIGASHI <higashi <at> taiju.info>
To: 57694 <at> debbugs.gnu.org
Cc: Taiju HIGASHI <higashi <at> taiju.info>
Subject: [PATCH 1/1] import: gem: Support for importing a specified version of
 a gem.
Date: Fri,  9 Sep 2022 22:47:36 +0900
* guix/import/gem.scm: (rubygems-fetch, gem->guix-package)
(gem-recursive-import): Fix to fetch the specified version of the gem.
* guix/scripts/import/gem.scm (show-help): Modify the help message.
(guix-import-gem): Modify the version number to be passed to subsequent
procedures
* tests/gem.scm: Add tests.
---
 guix/import/gem.scm         |  19 ++++--
 guix/scripts/import/gem.scm |  39 +++++++------
 tests/gem.scm               | 113 ++++++++++++++++++++++++++++++++++++
 3 files changed, 148 insertions(+), 23 deletions(-)

diff --git a/guix/import/gem.scm b/guix/import/gem.scm
index 0e5bb7e635..ad1343bff4 100644
--- a/guix/import/gem.scm
+++ b/guix/import/gem.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2020, 2021 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2020 Martin Becze <mjbecze <at> riseup.net>
 ;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
+;;; Copyright © 2022 Taiju HIGASHI <higashi <at> taiju.info>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -81,10 +82,12 @@ (define-json-mapping <gem-dependency> make-gem-dependency gem-dependency?
   (requirements  gem-dependency-requirements))    ;string
 
 
-(define (rubygems-fetch name)
-  "Return a <gem> record for the package NAME, or #f on failure."
+(define* (rubygems-fetch name #:optional version)
+  "Return a <gem> record for the package NAME and VERSION, or #f on failure.  If VERSION is #f or missing, return the latest version gem."
   (and=> (json-fetch
-          (string-append "https://rubygems.org/api/v1/gems/" name ".json"))
+          (if version
+              (string-append "https://rubygems.org/api/v2/rubygems/" name "/versions/" version ".json")
+              (string-append "https://rubygems.org/api/v1/gems/" name ".json")))
          json->gem))
 
 (define (ruby-package-name name)
@@ -122,8 +125,11 @@ (define (make-gem-sexp name version hash home-page synopsis description
 
 (define* (gem->guix-package package-name #:key (repo 'rubygems) version)
   "Fetch the metadata for PACKAGE-NAME from rubygems.org, and return the
-`package' s-expression corresponding to that package, or #f on failure."
-  (let ((gem (rubygems-fetch package-name)))
+`package' s-expression corresponding to that package, or #f on failure.
+Optionally include a VERSION string to fetch a specific version gem."
+  (let ((gem (if version
+                 (rubygems-fetch package-name version)
+                 (rubygems-fetch package-name))))
     (if gem
         (let* ((dependencies-names (map gem-dependency-name
                                         (gem-dependencies-runtime
@@ -189,4 +195,5 @@ (define* (gem-recursive-import package-name #:optional version)
   (recursive-import package-name
                     #:repo '()
                     #:repo->guix-package gem->guix-package
-                    #:guix-name ruby-package-name))
+                    #:guix-name ruby-package-name
+                    #:version version))
diff --git a/guix/scripts/import/gem.scm b/guix/scripts/import/gem.scm
index 82deac16ad..2e646e4475 100644
--- a/guix/scripts/import/gem.scm
+++ b/guix/scripts/import/gem.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
 ;;; Copyright © 2021 Brice Waegeneire <brice <at> waegenei.re>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune <at> gmail.com>
+;;; Copyright © 2022 Taiju HIGASHI <higashi <at> taiju.info>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -31,6 +32,7 @@ (define-module (guix scripts import gem)
   #:use-module (srfi srfi-37)
   #:use-module (ice-9 match)
   #:use-module (ice-9 format)
+  #:use-module (ice-9 receive)
   #:export (guix-import-gem))
 
 
@@ -42,8 +44,9 @@ (define %default-options
   '())
 
 (define (show-help)
-  (display (G_ "Usage: guix import gem PACKAGE-NAME
-Import and convert the RubyGems package for PACKAGE-NAME.\n"))
+  (display (G_ "Usage: guix import gem PACKAGE-NAME[@VERSION]
+Import and convert the RubyGems package for PACKAGE-NAME.  Optionally, a
+version can be specified after the arobas (@) character.\n"))
   (display (G_ "
   -h, --help             display this help and exit"))
   (display (G_ "
@@ -86,21 +89,23 @@ (define (parse-options)
                              (_ #f))
                            (reverse opts))))
     (match args
-      ((package-name)
-       (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))))
+      ((spec)
+       (receive (package-name package-version)
+           (package-name->name+version spec)
+         (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 package-version))
+                         (let ((sexp (gem->guix-package package-name #:version package-version)))
+                           (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 ...)
diff --git a/tests/gem.scm b/tests/gem.scm
index c8fe15398e..6aa0d279dc 100644
--- a/tests/gem.scm
+++ b/tests/gem.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2016 Ricardo Wurmus <rekado <at> elephly.net>
 ;;; Copyright © 2018 Oleg Pykhalov <go.wigust <at> gmail.com>
 ;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
+;;; Copyright © 2022 Taiju HIGASHI <higashi <at> taiju.info>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -44,6 +45,22 @@ (define test-foo-json
   \"licenses\": [\"MIT\", \"Apache 2.0\"]
 }")
 
+(define test-foo-v2-json
+  "{
+  \"name\": \"foo\",
+  \"version\": \"2.0.0\",
+  \"sha\": \"f3676eafca9987cb5fe263df1edf2538bf6dafc712b30e17be3543a9680547a8\",
+  \"info\": \"A cool gem\",
+  \"homepage_uri\": \"https://example.com\",
+  \"dependencies\": {
+    \"runtime\": [
+      { \"name\": \"bundler\" },
+      { \"name\": \"bar\" }
+    ]
+  },
+  \"licenses\": [\"MIT\", \"Apache 2.0\"]
+}")
+
 (define test-bar-json
   "{
   \"name\": \"bar\",
@@ -103,6 +120,35 @@ (define test-bundler-json
       (x
        (pk 'fail x #f)))))
 
+(test-assert "gem->guix-package with a specific version"
+  ;; Replace network resources with sample data.
+  (mock ((guix http-client) http-fetch
+         (lambda (url . rest)
+           (match url
+             ("https://rubygems.org/api/v2/rubygems/foo/versions/2.0.0.json"
+              (values (open-input-string test-foo-v2-json)
+                      (string-length test-foo-v2-json)))
+             (_ (error "Unexpected URL: " url)))))
+    (match (gem->guix-package "foo" #:version "2.0.0")
+      (('package
+         ('name "ruby-foo")
+         ('version "2.0.0")
+         ('source ('origin
+                    ('method 'url-fetch)
+                    ('uri ('rubygems-uri "foo" 'version))
+                    ('sha256
+                     ('base32
+                      "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk"))))
+         ('build-system 'ruby-build-system)
+         ('propagated-inputs ('list 'bundler 'ruby-bar))
+         ('synopsis "A cool gem")
+         ('description "This package provides a cool gem")
+         ('home-page "https://example.com")
+         ('license ('list 'license:expat 'license:asl2.0)))
+       #t)
+      (x
+       (pk 'fail x #f)))))
+
 (test-assert "gem-recursive-import"
   ;; Replace network resources with sample data.
   (mock ((guix http-client) http-fetch
@@ -170,4 +216,71 @@ (define test-bundler-json
           (x
            (pk 'fail x #f)))))
 
+(test-assert "gem-recursive-import with a specific version"
+  ;; Replace network resources with sample data.
+  (mock ((guix http-client) http-fetch
+         (lambda (url . rest)
+           (match url
+             ("https://rubygems.org/api/v2/rubygems/foo/versions/2.0.0.json"
+              (values (open-input-string test-foo-v2-json)
+                      (string-length test-foo-v2-json)))
+             ("https://rubygems.org/api/v1/gems/bar.json"
+              (values (open-input-string test-bar-json)
+                      (string-length test-bar-json)))
+             ("https://rubygems.org/api/v1/gems/bundler.json"
+              (values (open-input-string test-bundler-json)
+                      (string-length test-bundler-json)))
+             (_ (error "Unexpected URL: " url)))))
+        (match (gem-recursive-import "foo" "2.0.0")
+          ((('package
+              ('name "ruby-bar")
+              ('version "1.0.0")
+              ('source
+               ('origin
+                 ('method 'url-fetch)
+                 ('uri ('rubygems-uri "bar" 'version))
+                 ('sha256
+                  ('base32
+                   "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk"))))
+              ('build-system 'ruby-build-system)
+              ('propagated-inputs ('list 'bundler))
+              ('synopsis "Another cool gem")
+              ('description "Another cool gem")
+              ('home-page "https://example.com")
+              ('license #f))                      ;no licensing info
+            ('package
+              ('name "ruby-bundler")
+              ('version "1.14.2")
+              ('source
+               ('origin
+                 ('method 'url-fetch)
+                 ('uri ('rubygems-uri "bundler" 'version))
+                 ('sha256
+                  ('base32
+                   "1446xiz7zg0bz7kgx9jv84y0s4hpsg61dj5l3qb0i00avc1kxd9v"))))
+              ('build-system 'ruby-build-system)
+              ('synopsis "Ruby gem bundler")
+              ('description "Ruby gem bundler")
+              ('home-page "https://bundler.io/")
+              ('license 'license:expat))
+            ('package
+              ('name "ruby-foo")
+              ('version "2.0.0")
+              ('source
+               ('origin
+                 ('method 'url-fetch)
+                 ('uri ('rubygems-uri "foo" 'version))
+                 ('sha256
+                  ('base32
+                   "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk"))))
+              ('build-system 'ruby-build-system)
+              ('propagated-inputs ('list 'bundler 'ruby-bar))
+              ('synopsis "A cool gem")
+              ('description "This package provides a cool gem")
+              ('home-page "https://example.com")
+              ('license ('list 'license:expat 'license:asl2.0))))
+           #t)
+          (x
+           (pk 'fail x #f)))))
+
 (test-end "gem")
-- 
2.37.2





Information forwarded to guix-patches <at> gnu.org:
bug#57694; Package guix-patches. (Wed, 14 Sep 2022 09:56:03 GMT) Full text and rfc822 format available.

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

From: Taiju HIGASHI <higashi <at> taiju.info>
To: mail <at> cbaines.net
Cc: 57694 <at> debbugs.gnu.org
Subject: Re: [PATCH 1/1] import: gem: Support for importing a specified
 version of a gem.
Date: Wed, 14 Sep 2022 18:55:45 +0900
Hi Chris,

Could you give me your opinion on this patch?
Is this patch worth it?

Taiju HIGASHI <higashi <at> taiju.info> writes:

> * guix/import/gem.scm: (rubygems-fetch, gem->guix-package)
> (gem-recursive-import): Fix to fetch the specified version of the gem.
> * guix/scripts/import/gem.scm (show-help): Modify the help message.
> (guix-import-gem): Modify the version number to be passed to subsequent
> procedures
> * tests/gem.scm: Add tests.
> ---
>  guix/import/gem.scm         |  19 ++++--
>  guix/scripts/import/gem.scm |  39 +++++++------
>  tests/gem.scm               | 113 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 148 insertions(+), 23 deletions(-)
>
> diff --git a/guix/import/gem.scm b/guix/import/gem.scm
> index 0e5bb7e635..ad1343bff4 100644
> --- a/guix/import/gem.scm
> +++ b/guix/import/gem.scm
> @@ -5,6 +5,7 @@
>  ;;; Copyright © 2020, 2021 Ludovic Courtès <ludo <at> gnu.org>
>  ;;; Copyright © 2020 Martin Becze <mjbecze <at> riseup.net>
>  ;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
> +;;; Copyright © 2022 Taiju HIGASHI <higashi <at> taiju.info>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -81,10 +82,12 @@ (define-json-mapping <gem-dependency> make-gem-dependency gem-dependency?
>    (requirements  gem-dependency-requirements))    ;string
>
>  
> -(define (rubygems-fetch name)
> -  "Return a <gem> record for the package NAME, or #f on failure."
> +(define* (rubygems-fetch name #:optional version)
> +  "Return a <gem> record for the package NAME and VERSION, or #f on failure.  If VERSION is #f or missing, return the latest version gem."
>    (and=> (json-fetch
> -          (string-append "https://rubygems.org/api/v1/gems/" name ".json"))
> +          (if version
> +              (string-append "https://rubygems.org/api/v2/rubygems/" name "/versions/" version ".json")
> +              (string-append "https://rubygems.org/api/v1/gems/" name ".json")))
>           json->gem))
>
>  (define (ruby-package-name name)
> @@ -122,8 +125,11 @@ (define (make-gem-sexp name version hash home-page synopsis description
>
>  (define* (gem->guix-package package-name #:key (repo 'rubygems) version)
>    "Fetch the metadata for PACKAGE-NAME from rubygems.org, and return the
> -`package' s-expression corresponding to that package, or #f on failure."
> -  (let ((gem (rubygems-fetch package-name)))
> +`package' s-expression corresponding to that package, or #f on failure.
> +Optionally include a VERSION string to fetch a specific version gem."
> +  (let ((gem (if version
> +                 (rubygems-fetch package-name version)
> +                 (rubygems-fetch package-name))))
>      (if gem
>          (let* ((dependencies-names (map gem-dependency-name
>                                          (gem-dependencies-runtime
> @@ -189,4 +195,5 @@ (define* (gem-recursive-import package-name #:optional version)
>    (recursive-import package-name
>                      #:repo '()
>                      #:repo->guix-package gem->guix-package
> -                    #:guix-name ruby-package-name))
> +                    #:guix-name ruby-package-name
> +                    #:version version))
> diff --git a/guix/scripts/import/gem.scm b/guix/scripts/import/gem.scm
> index 82deac16ad..2e646e4475 100644
> --- a/guix/scripts/import/gem.scm
> +++ b/guix/scripts/import/gem.scm
> @@ -4,6 +4,7 @@
>  ;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
>  ;;; Copyright © 2021 Brice Waegeneire <brice <at> waegenei.re>
>  ;;; Copyright © 2021 Simon Tournier <zimon.toutoune <at> gmail.com>
> +;;; Copyright © 2022 Taiju HIGASHI <higashi <at> taiju.info>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -31,6 +32,7 @@ (define-module (guix scripts import gem)
>    #:use-module (srfi srfi-37)
>    #:use-module (ice-9 match)
>    #:use-module (ice-9 format)
> +  #:use-module (ice-9 receive)
>    #:export (guix-import-gem))
>
>  
> @@ -42,8 +44,9 @@ (define %default-options
>    '())
>
>  (define (show-help)
> -  (display (G_ "Usage: guix import gem PACKAGE-NAME
> -Import and convert the RubyGems package for PACKAGE-NAME.\n"))
> +  (display (G_ "Usage: guix import gem PACKAGE-NAME[@VERSION]
> +Import and convert the RubyGems package for PACKAGE-NAME.  Optionally, a
> +version can be specified after the arobas (@) character.\n"))
>    (display (G_ "
>    -h, --help             display this help and exit"))
>    (display (G_ "
> @@ -86,21 +89,23 @@ (define (parse-options)
>                               (_ #f))
>                             (reverse opts))))
>      (match args
> -      ((package-name)
> -       (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))))
> +      ((spec)
> +       (receive (package-name package-version)
> +           (package-name->name+version spec)
> +         (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 package-version))
> +                         (let ((sexp (gem->guix-package package-name #:version package-version)))
> +                           (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 ...)
> diff --git a/tests/gem.scm b/tests/gem.scm
> index c8fe15398e..6aa0d279dc 100644
> --- a/tests/gem.scm
> +++ b/tests/gem.scm
> @@ -3,6 +3,7 @@
>  ;;; Copyright © 2016 Ricardo Wurmus <rekado <at> elephly.net>
>  ;;; Copyright © 2018 Oleg Pykhalov <go.wigust <at> gmail.com>
>  ;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
> +;;; Copyright © 2022 Taiju HIGASHI <higashi <at> taiju.info>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -44,6 +45,22 @@ (define test-foo-json
>    \"licenses\": [\"MIT\", \"Apache 2.0\"]
>  }")
>
> +(define test-foo-v2-json
> +  "{
> +  \"name\": \"foo\",
> +  \"version\": \"2.0.0\",
> +  \"sha\": \"f3676eafca9987cb5fe263df1edf2538bf6dafc712b30e17be3543a9680547a8\",
> +  \"info\": \"A cool gem\",
> +  \"homepage_uri\": \"https://example.com\",
> +  \"dependencies\": {
> +    \"runtime\": [
> +      { \"name\": \"bundler\" },
> +      { \"name\": \"bar\" }
> +    ]
> +  },
> +  \"licenses\": [\"MIT\", \"Apache 2.0\"]
> +}")
> +
>  (define test-bar-json
>    "{
>    \"name\": \"bar\",
> @@ -103,6 +120,35 @@ (define test-bundler-json
>        (x
>         (pk 'fail x #f)))))
>
> +(test-assert "gem->guix-package with a specific version"
> +  ;; Replace network resources with sample data.
> +  (mock ((guix http-client) http-fetch
> +         (lambda (url . rest)
> +           (match url
> +             ("https://rubygems.org/api/v2/rubygems/foo/versions/2.0.0.json"
> +              (values (open-input-string test-foo-v2-json)
> +                      (string-length test-foo-v2-json)))
> +             (_ (error "Unexpected URL: " url)))))
> +    (match (gem->guix-package "foo" #:version "2.0.0")
> +      (('package
> +         ('name "ruby-foo")
> +         ('version "2.0.0")
> +         ('source ('origin
> +                    ('method 'url-fetch)
> +                    ('uri ('rubygems-uri "foo" 'version))
> +                    ('sha256
> +                     ('base32
> +                      "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk"))))
> +         ('build-system 'ruby-build-system)
> +         ('propagated-inputs ('list 'bundler 'ruby-bar))
> +         ('synopsis "A cool gem")
> +         ('description "This package provides a cool gem")
> +         ('home-page "https://example.com")
> +         ('license ('list 'license:expat 'license:asl2.0)))
> +       #t)
> +      (x
> +       (pk 'fail x #f)))))
> +
>  (test-assert "gem-recursive-import"
>    ;; Replace network resources with sample data.
>    (mock ((guix http-client) http-fetch
> @@ -170,4 +216,71 @@ (define test-bundler-json
>            (x
>             (pk 'fail x #f)))))
>
> +(test-assert "gem-recursive-import with a specific version"
> +  ;; Replace network resources with sample data.
> +  (mock ((guix http-client) http-fetch
> +         (lambda (url . rest)
> +           (match url
> +             ("https://rubygems.org/api/v2/rubygems/foo/versions/2.0.0.json"
> +              (values (open-input-string test-foo-v2-json)
> +                      (string-length test-foo-v2-json)))
> +             ("https://rubygems.org/api/v1/gems/bar.json"
> +              (values (open-input-string test-bar-json)
> +                      (string-length test-bar-json)))
> +             ("https://rubygems.org/api/v1/gems/bundler.json"
> +              (values (open-input-string test-bundler-json)
> +                      (string-length test-bundler-json)))
> +             (_ (error "Unexpected URL: " url)))))
> +        (match (gem-recursive-import "foo" "2.0.0")
> +          ((('package
> +              ('name "ruby-bar")
> +              ('version "1.0.0")
> +              ('source
> +               ('origin
> +                 ('method 'url-fetch)
> +                 ('uri ('rubygems-uri "bar" 'version))
> +                 ('sha256
> +                  ('base32
> +                   "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk"))))
> +              ('build-system 'ruby-build-system)
> +              ('propagated-inputs ('list 'bundler))
> +              ('synopsis "Another cool gem")
> +              ('description "Another cool gem")
> +              ('home-page "https://example.com")
> +              ('license #f))                      ;no licensing info
> +            ('package
> +              ('name "ruby-bundler")
> +              ('version "1.14.2")
> +              ('source
> +               ('origin
> +                 ('method 'url-fetch)
> +                 ('uri ('rubygems-uri "bundler" 'version))
> +                 ('sha256
> +                  ('base32
> +                   "1446xiz7zg0bz7kgx9jv84y0s4hpsg61dj5l3qb0i00avc1kxd9v"))))
> +              ('build-system 'ruby-build-system)
> +              ('synopsis "Ruby gem bundler")
> +              ('description "Ruby gem bundler")
> +              ('home-page "https://bundler.io/")
> +              ('license 'license:expat))
> +            ('package
> +              ('name "ruby-foo")
> +              ('version "2.0.0")
> +              ('source
> +               ('origin
> +                 ('method 'url-fetch)
> +                 ('uri ('rubygems-uri "foo" 'version))
> +                 ('sha256
> +                  ('base32
> +                   "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk"))))
> +              ('build-system 'ruby-build-system)
> +              ('propagated-inputs ('list 'bundler 'ruby-bar))
> +              ('synopsis "A cool gem")
> +              ('description "This package provides a cool gem")
> +              ('home-page "https://example.com")
> +              ('license ('list 'license:expat 'license:asl2.0))))
> +           #t)
> +          (x
> +           (pk 'fail x #f)))))
> +
>  (test-end "gem")

Cheers,
-- 
Taiju




Reply sent to Christopher Baines <mail <at> cbaines.net>:
You have taken responsibility. (Sat, 17 Sep 2022 17:20:02 GMT) Full text and rfc822 format available.

Notification sent to Taiju HIGASHI <higashi <at> taiju.info>:
bug acknowledged by developer. (Sat, 17 Sep 2022 17:20:02 GMT) Full text and rfc822 format available.

Message #16 received at 57694-done <at> debbugs.gnu.org (full text, mbox):

From: Christopher Baines <mail <at> cbaines.net>
To: Taiju HIGASHI <higashi <at> taiju.info>
Cc: 57694-done <at> debbugs.gnu.org
Subject: Re: [PATCH 1/1] import: gem: Support for importing a specified
 version of a gem.
Date: Sat, 17 Sep 2022 19:18:41 +0200
[Message part 1 (text/plain, inline)]
Taiju HIGASHI <higashi <at> taiju.info> writes:

> Hi Chris,
>
> Could you give me your opinion on this patch?
> Is this patch worth it?

Hey,

Unfortunately I haven't had much time to look at Ruby stuff recently,
but these changes look good to me. I tweaked a few minor things and
pushed this as c967d1153cae419e4acbe0dbed8f558d95ced0e3.

Thanks,

Chris

> Taiju HIGASHI <higashi <at> taiju.info> writes:
>
>> * guix/import/gem.scm: (rubygems-fetch, gem->guix-package)
>> (gem-recursive-import): Fix to fetch the specified version of the gem.
>> * guix/scripts/import/gem.scm (show-help): Modify the help message.
>> (guix-import-gem): Modify the version number to be passed to subsequent
>> procedures
>> * tests/gem.scm: Add tests.
>> ---
>>  guix/import/gem.scm         |  19 ++++--
>>  guix/scripts/import/gem.scm |  39 +++++++------
>>  tests/gem.scm               | 113 ++++++++++++++++++++++++++++++++++++
>>  3 files changed, 148 insertions(+), 23 deletions(-)

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#57694; Package guix-patches. (Sat, 17 Sep 2022 23:53:02 GMT) Full text and rfc822 format available.

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

From: Taiju HIGASHI <higashi <at> taiju.info>
To: Christopher Baines <mail <at> cbaines.net>
Cc: 57694 <at> debbugs.gnu.org
Subject: Re: [PATCH 1/1] import: gem: Support for importing a specified
 version of a gem.
Date: Sun, 18 Sep 2022 08:52:06 +0900
Hi Chris,

Thank you for merging!

Sorry to interrupt your busy schedule at the event.
I'm watching the live streaming and enjoying the event too!

Happy Birthday,
-- 
Taiju




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 16 Oct 2022 11:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 164 days ago.

Previous Next


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