Subject: [bug#62202] [PATCH v2 08/23] DRAFT import: juliahub: Add updater and recursive-importer.

From: Simon Tournier <[email-masked]>
Date: Mon, 18 Sep 2023 20:03:15 +0200

From: Nicolas Graves via Guix-patches via <[email-masked]>

Signed-off-by: Simon Tournier <[email-masked]>
---
 guix/import/juliahub.scm | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/guix/import/juliahub.scm b/guix/import/juliahub.scm
index fb361a004435..c38c830caaa0 100644
--- a/guix/import/juliahub.scm
+++ b/guix/import/juliahub.scm
@@ -34,7 +34,9 @@ (define-module (guix import juliahub)
   #:use-module (json)
   #:use-module ((guix licenses) #:prefix license:)
 
-  #:export (juliahub->guix-package))
+  #:export (juliahub->guix-package
+            %juliahub-updater
+            juliahub-recursive-import))
 
 (define (juliahub-uri name)
   (let* ((url (string-append "https://docs.juliahub.com/" name "/"))
@@ -197,16 +199,26 @@ (define* (juliahub->guix-package package-name
                     (append dependencies-names test-dependencies-names))))
         (values #f '()))))
 
+(define (guix-package->juliahub-name package)
+  (let* ((url (juliahub-package-url package))
+         (git-name (car (last-pair (string-split url #\/))))
+         (ungitted-name (if (string-suffix? ".git" git-name)
+                            (string-drop-right git-name 4)
+                            git-name))
+         (package-name (if (string-suffix? ".jl" ungitted-name)
+                            (string-drop-right ungitted-name 4)
+                            ungitted-name)))
+    package-name))
+
 (define* (import-release package #:key (version #f))
   "Return an <upstream-source> for the latest release of PACKAGE."
   (let* ((package-name (guix-package->juliahub-name package))
          (package      (juliahub-fetch package-name))
-         (version  (or version (juliahub-version gem)))
-         (url      (rubyjuliahubs-uri gem-name version)))
+         (version  (or version (juliahub-package-version package))))
     (upstream-source
      (package (package-name package))
      (version version)
-     (urls (list url)))))
+     (urls (list (juliahub-package-url package))))))
 
 (define %juliahub-updater
   (upstream-updater
@@ -219,5 +231,5 @@ (define* (juliahub-recursive-import package-name #:optional version)
   (recursive-import package-name
                     #:repo '()
                     #:repo->guix-package juliahub->guix-package
-                    #:guix-name ruby-package-name
+                    #:guix-name julia-name->guix-name
                     #:version version))
-- 
2.38.1