guix_mirror_bot pushed a commit to branch r-team
in repository guix.

commit 61a54444107dbe9ce8e500ac687423a9f47460b2
Author: Ricardo Wurmus <[email protected]>
AuthorDate: Mon Feb 16 19:15:03 2026 +0100

    import/cran: Fix import of packages in single quotes.
    
    * guix/import/cran.scm (import-pattern): Also match on single quotes.
    (needed-vignettes-inputs-in-directory): Use EXTRACT-IMPORTS.
    * tests/import/cran.scm: Add test.
    
    Change-Id: Ie69027992519bd8d886860346f4a359514d8e822
---
 guix/import/cran.scm  | 18 ++++++------------
 tests/import/cran.scm |  7 ++++++-
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/guix/import/cran.scm b/guix/import/cran.scm
index a53e75a71b..9c31f50e3e 100644
--- a/guix/import/cran.scm
+++ b/guix/import/cran.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015-2025 Ricardo Wurmus <[email protected]>
+;;; Copyright © 2015-2026 Ricardo Wurmus <[email protected]>
 ;;; Copyright © 2015-2017, 2019-2021, 2023 Ludovic Courtès <[email protected]>
 ;;; Copyright © 2017 Mathieu Othacehe <[email protected]>
 ;;; Copyright © 2020 Martin Becze <[email protected]>
@@ -570,7 +570,7 @@ referenced in build system files."
     ;; Quiet imports
     "(suppressPackageStartupMessages\\()?"
     ;; the actual import statement.
-    "(require|library|check_installed)\\(\"?([^, \")]+)"
+    "(require|library|check_installed)\\([\"']?([^, \"')]+)"
     ;; Or perhaps...
     "|"
     ;; ...direct namespace access.
@@ -654,16 +654,10 @@ in vignette files in the directory DIR."
                            (cond
                             ((eof-object? line) packages)
                             (else
-                             (loop
-                              (fold (lambda (match acc)
-                                      (let ((imported (match:substring match 
4)))
-                                        (if (or (not imported)
-                                                (string=? imported 
package-directory-name)
-                                                (member imported 
default-r-packages))
-                                            acc
-                                            (set-insert imported acc))))
-                                    packages
-                                    (list-matches import-pattern line))))))))))
+                             (loop (extract-imports line
+                                                    #:initial-set packages
+                                                    #:ignored-names (cons 
package-directory-name
+                                                                          
default-r-packages))))))))))
                  (set)
                  (append-map (lambda (directory)
                                (find-files directory "\\.Rnw"))
diff --git a/tests/import/cran.scm b/tests/import/cran.scm
index 0b6303370a..19fd580931 100644
--- a/tests/import/cran.scm
+++ b/tests/import/cran.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015, 2025 Ricardo Wurmus <[email protected]>
+;;; Copyright © 2015, 2025-2026 Ricardo Wurmus <[email protected]>
 ;;; Copyright © 2017 Mathieu Othacehe <[email protected]>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -98,6 +98,11 @@ Date/Publication: 2015-07-14 14:15:16
   (set->list ((@ (guix import cran) extract-imports)
               "\"hello::world\", \"this is not data.table::some_procedure(), 
actually\"")))
 
+(test-equal "extract-imports: extracts text inside single quotes"
+  (list "FDb.InfiniumMethylation.hg19")
+  (set->list ((@ (guix import cran) extract-imports)
+              
"suppressPackageStartupMessages(require('FDb.InfiniumMethylation.hg19'))")))
+
 (test-equal "extract-imports: ignores other colon separated things"
   (list)
   (set->list ((@ (guix import cran) extract-imports)

Reply via email to