unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Martin Becze <mjbecze@riseup.net>
To: 37322@debbugs.gnu.org
Cc: Martin Becze <mjbecze@riseup.net>
Subject: [bug#37322] [PATCH 1/2] adds the capability of importing a specified version to the crate importer
Date: Fri,  6 Sep 2019 11:32:10 -0400	[thread overview]
Message-ID: <20190906153211.8613-1-mjbecze@riseup.net> (raw)

---
 guix/import/crate.scm | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index f6057dbf8b..3266ebdfec 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016 David Craven <david@craven.ch>
 ;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2019 Martin Becze <mjbecze@riseup.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -181,8 +182,8 @@ and LICENSE."
   ;; This regexp matches that.
   (make-regexp "^(.*) OR (.*)$"))
 
-(define (crate->guix-package crate-name)
-  "Fetch the metadata for CRATE-NAME from crates.io, and return the
+(define (crate->guix-package crate-name@version)
+  "Fetch the metadata for CRATE-NAME@VERSION from crates.io, and return the
 `package' s-expression corresponding to that package, or #f on failure."
   (define (string->license string)
     (match (regexp-exec %dual-license-rx string)
@@ -193,13 +194,29 @@ and LICENSE."
   (define (normal-dependency? dependency)
     (eq? (crate-dependency-kind dependency) 'normal))
 
+  (define crate-name-version-list
+    (let ((lnv (string-split crate-name@version #\@)))
+      (if (= 1 (length lnv))
+	  (append lnv '(#f))
+	  lnv)))
+
+  (define crate-name
+    (car crate-name-version-list))
+
+
   (define crate
     (lookup-crate crate-name))
 
+  (define crate-version-string
+    (let ((version (cadr crate-name-version-list)))
+      (if version
+        version
+        (crate-latest-version crate))))
+
   (and crate
        (let* ((version        (find (lambda (version)
                                       (string=? (crate-version-number version)
-                                                (crate-latest-version crate)))
+                                                crate-version-string))
                                     (crate-versions crate)))
               (dependencies   (crate-version-dependencies version))
               (dep-crates     (filter normal-dependency? dependencies))
-- 
2.23.0

             reply	other threads:[~2019-09-06 15:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-06 15:32 Martin Becze [this message]
2019-09-06 15:32 ` [bug#37323] [PATCH 2/2] updated import crate docs Martin Becze
2019-09-08 12:27 ` [bug#37322] [PATCH 1/2] adds the capability of importing a specified version to the crate importer Ludovic Courtès
2019-09-09 15:32   ` Martin Becze

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190906153211.8613-1-mjbecze@riseup.net \
    --to=mjbecze@riseup.net \
    --cc=37322@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).