Subject: [PATCH 13/20] refresh: Allow updating to a specific version (launchpad)

From: Hartmut Goebel <[email-masked]>
Date: Sun, 28 Aug 2022 15:18:39 +0200

* guix/import/launchpad.scm(latest-release): Rename to (import-release),
  add keyword-argument 'version'.
  If version is given, return an upstream-source for this version.
---
 guix/import/launchpad.scm | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/guix/import/launchpad.scm b/guix/import/launchpad.scm
index b7e0295c4e..2112eefe1d 100644
--- a/guix/import/launchpad.scm
+++ b/guix/import/launchpad.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2019, 2020 Arun Isaac <[email-masked]>
 ;;; Copyright © 2021 Matthew James Kraai <[email-masked]>
 ;;; Copyright © 2020 Brice Waegeneire <[email-masked]>
+;;; Copyright © 2022 Hartmut Goebel <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -121,7 +122,7 @@ for example, 'linuxdcpp'. Return #f if there is no releases."
       (last (remove pre-release? (vector->list (assoc-ref json "entries"))))
       "version"))))
 
-(define (latest-release pkg)
+(define* (import-release pkg #:key (version #f))
   "Return an <upstream-source> for the latest release of PKG."
   (define (origin-launchpad-uri origin)
     (match (origin-uri origin)
@@ -132,7 +133,7 @@ for example, 'linuxdcpp'. Return #f if there is no releases."
   (let* ((source-uri (origin-launchpad-uri (package-source pkg)))
          (name (package-name pkg))
          (repository (launchpad-repository source-uri))
-         (newest-version (latest-released-version repository)))
+         (newest-version (or version (latest-released-version repository))))
     (if newest-version
         (upstream-source
          (package name)
@@ -145,4 +146,4 @@ for example, 'linuxdcpp'. Return #f if there is no releases."
    (name 'launchpad)
    (description "Updater for Launchpad packages")
    (pred launchpad-package?)
-   (import latest-release)))
+   (import import-release)))
-- 
2.30.4