From patchwork Sun Aug 28 13:18:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 42031 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 1609727BBEA; Sun, 28 Aug 2022 14:20:53 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8DD1027BBE9 for ; Sun, 28 Aug 2022 14:20:52 +0100 (BST) Received: from localhost ([::1]:46714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSIDb-000477-Nc for patchwork@mira.cbaines.net; Sun, 28 Aug 2022 09:20:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSICs-0002q3-TB for guix-patches@gnu.org; Sun, 28 Aug 2022 09:20:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39837) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oSICs-0002ef-KE for guix-patches@gnu.org; Sun, 28 Aug 2022 09:20:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oSICs-0006yM-Fa for guix-patches@gnu.org; Sun, 28 Aug 2022 09:20:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57460] [PATCH 08/20] refresh: Allow updating to a specific version (git) Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 28 Aug 2022 13:20:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57460 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57460@debbugs.gnu.org Received: via spool by 57460-submit@debbugs.gnu.org id=B57460.166169275926559 (code B ref 57460); Sun, 28 Aug 2022 13:20:06 +0000 Received: (at 57460) by debbugs.gnu.org; 28 Aug 2022 13:19:19 +0000 Received: from localhost ([127.0.0.1]:57781 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSIC6-0006u7-Nq for submit@debbugs.gnu.org; Sun, 28 Aug 2022 09:19:19 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:46849) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSIC1-0006sz-Vf for 57460@debbugs.gnu.org; Sun, 28 Aug 2022 09:19:14 -0400 Received: from hermia.goebel-consult.de ([46.87.137.46]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MtOX2-1pHVAL3q8c-00uu6c for <57460@debbugs.gnu.org>; Sun, 28 Aug 2022 15:19:07 +0200 Received: from lenashee.fritz.box (lenashee.goebel-consult.de [192.168.110.2]) by hermia.goebel-consult.de (Postfix) with ESMTP id D076865A3A; Sun, 28 Aug 2022 15:18:55 +0200 (CEST) From: Hartmut Goebel Date: Sun, 28 Aug 2022 15:18:34 +0200 Message-Id: X-Mailer: git-send-email 2.30.4 In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:geru7qQfw13bFNoFDMDerTnXHUgMdCsmemtrIJ1PcnPFSB5Wxt6 GiASyotvnOFnz80M8b0+zeNVS+BtmLDNl02XwVUK9cXb+xZfGurblfj0P4o00nvRFA0Pu7M DkrNIL1WxZ+oLGDoqcOt7wPq6Kj6zFHkJ7uR+sA7O2RWWd7Hyab0lK2IURHPiBNcWrimwHb Gi/mrWSIF4KnLxmLLCjVg== X-UI-Out-Filterresults: notjunk:1;V03:K0:t5VATJLeJ+Q=:CejxlN3BrksAyx2CoCx9Qg 1VVKSi9FfbNsVeBsMxU3DvVw9d5G/d4RXiX1fPAB2jvQKzfJsg1vSq+FBU4UF9Acsr65rj+5v SVXI2w/1PRFhiLOyxdE81/yVnMOqfe0ejZhdwH9W6yJPU7pNTCp6Vnb1/PesAQyYb+kYHrks0 yhMdQSopnoV4afPRNX2INXmO9HruDOxJbW0bjt3RndPkF8R2Y+cKGDESJ1UoXe0WXX1RtFVUG gDdXbkjJMAM6DorMD4TnPShPMqdqUoWRvrtPpfmDukaJ/mtt4GD/86IfbJAtb+uB4xo9kwiZq wT3FeSwOthJd6pxVkUMsdRf98JxMnQMQJBjnUZow8PFFdTchtgilOxKvKbEIw341kLfqNdmm4 hDeeRFZRKYEVpKeR7rdBDTyKAVGWnmn4ubfhcAzlCJ4GsXHz1sc+PCkn71k+tB0iHChPOoPva BmoIPixRZBoBdeX1L8wbTQdnluBXB96YQS6xFBbr6akAxYggZlkUZuNsA7gQfymP2gI1TB1P+ rFMp8Zli6esjPJ7148k2yWovspGyNkU2Al28EXUiPtfYBTN0Ayy2nfkhePeZH6I1bnIJmKP/b dy+bBu8/c86BtMcvIOsjkDOiZoaA2XlaYbQ16IgbI1ZkwMPAEqgFxI1wOkzzTpKoclMduh+og 6dnCyVmq9G0cAe6mYMcNZy0j92nf/lcetOPU58CsPEKG3JJIuy8NkzAVw7xcPv7ySDH/4uFlK Ku060t/Cw2x2CgWsDFouB84ZL6DCwVCOe45n+RHAr/+KuzwGUKplq4HVlcg= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/import/git.scm (latest-tag): Add keyword-argument 'version'. If version is given, try to find the respective version tag. (latest-git-tag-version): Add keyword-argument 'version' and pass it on to called functions. (latest-releease) Rename to (import-release), add keyword-argument 'version' and pass it on to called functions. --- guix/import/git.scm | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/guix/import/git.scm b/guix/import/git.scm index bb5ba4d97e..fdac51edfd 100644 --- a/guix/import/git.scm +++ b/guix/import/git.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2021 Xinglu Chen ;;; Copyright © 2021 Sarah Morgensen ;;; Copyright © 2022 Maxime Devos +;;; Copyright © 2022 Hartmut Goebel ;;; ;;; This file is part of GNU Guix. ;;; @@ -146,7 +147,8 @@ version corresponding to the tag, and the cdr is the name of the tag." tags) entrytags) (git-no-valid-tags-error)) (else - (match (last versions->tags) - ((version . tag) - (values version tag))))))) - -(define (latest-git-tag-version package) + (let ((version-to-pick + (if version + (filter (lambda (vt) (string=? version (car vt))) + versions->tags) + versions->tags))) + (if (null? version-to-pick) + (values #f #f) + (match (last version-to-pick) + ((version . tag) + (values version tag))))))))) + +(define* (latest-git-tag-version package #:key (version #f)) "Given a PACKAGE, return the latest version of it and the corresponding git tag, or #false and #false if the latest version could not be determined." (guard (c ((or (git-no-tags-error? c) (git-no-valid-tags-error? c)) @@ -193,6 +202,7 @@ tag, or #false and #false if the latest version could not be determined." (url (git-reference-url (origin-uri source))) (property (cute assq-ref (package-properties package) <>))) (latest-tag url + #:version version #:prefix (property 'release-tag-prefix) #:suffix (property 'release-tag-suffix) #:delim (property 'release-tag-version-delimiter) @@ -206,12 +216,13 @@ tag, or #false and #false if the latest version could not be determined." (git-reference? (origin-uri origin)))) (_ #f))) -(define (latest-git-release package) +(define* (import-git-release package #:key (version #f)) "Return an for the latest release of PACKAGE." (let* ((name (package-name package)) (old-version (package-version package)) (old-reference (origin-uri (package-source package))) - (new-version new-version-tag (latest-git-tag-version package))) + (new-version new-version-tag + (latest-git-tag-version package #:version version))) (and new-version new-version-tag (upstream-source (package name) @@ -226,4 +237,4 @@ tag, or #false and #false if the latest version could not be determined." (name 'generic-git) (description "Updater for packages hosted on Git repositories") (pred git-package?) - (import latest-git-release))) + (import import-git-release)))