From f21c70bc9a41d000acf7d39a0813a3c7415517ca Mon Sep 17 00:00:00 2001 From: Xinglu Chen Date: Fri, 17 Dec 2021 21:55:54 +0100 Subject: [PATCH] =?UTF-8?q?import:=20elpa:=20Support=20=E2=80=98upstream-n?= =?UTF-8?q?ame=E2=80=99=20property.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/import/elpa.scm: (guix-package->elpa-name): New procedure. (latest-release): Use it. * tests/elpa.scm ("guix-package->elpa-name: without 'upstream-name' property") ("guix-package->elpa-name: with 'upstream-name' property"): Test it. Signed-off-by: Ludovic Courtès --- guix/import/elpa.scm | 15 ++++++++++----- tests/elpa.scm | 12 ++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/guix/import/elpa.scm b/guix/import/elpa.scm index dd539cd945..edabb88b7a 100644 --- a/guix/import/elpa.scm +++ b/guix/import/elpa.scm @@ -46,6 +46,7 @@ #:use-module (guix packages) #:use-module ((guix utils) #:select (call-with-temporary-output-file)) #:export (elpa->guix-package + guix-package->elpa-name %elpa-updater elpa-recursive-import)) @@ -412,13 +413,17 @@ type ''." ;;; Updates. ;;; +(define (guix-package->elpa-name package) + "Given a Guix package, PACKAGE, return the upstream name on ELPA." + (or (and=> (package-properties package) + (cut assq-ref <> 'upstream-name)) + (if (string-prefix? "emacs-" (package-name package)) + (string-drop (package-name package) 6) + (package-name package)))) + (define (latest-release package) "Return an for the latest release of PACKAGE." - (define name - (if (string-prefix? "emacs-" (package-name package)) - (string-drop (package-name package) 6) - (package-name package))) - + (define name (guix-package->elpa-name package)) (define repo 'gnu) (match (elpa-package-info name repo) diff --git a/tests/elpa.scm b/tests/elpa.scm index 01ef948b2e..1efdf2457f 100644 --- a/tests/elpa.scm +++ b/tests/elpa.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2015 Federico Beffa ;;; Copyright © 2020 Ludovic Courtès ;;; Copyright © 2020 Martin Becze +;;; Copyright © 2021 Xinglu Chen ;;; ;;; This file is part of GNU Guix. ;;; @@ -20,6 +21,7 @@ (define-module (test-elpa) #:use-module (guix import elpa) + #:use-module (guix tests) #:use-module (guix tests http) #:use-module (srfi srfi-1) #:use-module (srfi srfi-64) @@ -71,6 +73,16 @@ (test-assert "elpa->guix-package test 1" (eval-test-with-elpa "auctex")) +(test-equal "guix-package->elpa-name: without 'upstream-name' property" + "auctex" + (guix-package->elpa-name (dummy-package "emacs-auctex"))) + +(test-equal "guix-package->elpa-name: with 'upstream-name' property" + "project" + (guix-package->elpa-name + (dummy-package "emacs-fake-name" + (properties '((upstream-name . "project")))))) + (test-end "elpa") ;; Local Variables: