From patchwork Tue Dec 20 09:34:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 45440 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 B8C7C27BBE9; Tue, 20 Dec 2022 09:38:05 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,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 9138927BBEB for ; Tue, 20 Dec 2022 09:38:03 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7Z2r-00056W-MW; Tue, 20 Dec 2022 04:36:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p7Z1g-0004fZ-AX for guix-patches@gnu.org; Tue, 20 Dec 2022 04:35:12 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p7Z1g-0002vn-0r for guix-patches@gnu.org; Tue, 20 Dec 2022 04:35:08 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p7Z1f-0003Rg-SX for guix-patches@gnu.org; Tue, 20 Dec 2022 04:35:07 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#57460] [PATCH v3 09/18] import: git: Allow updating to a specific version. Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 20 Dec 2022 09:35:07 +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 moreinfo To: 57460@debbugs.gnu.org Received: via spool by 57460-submit@debbugs.gnu.org id=B57460.167152890213144 (code B ref 57460); Tue, 20 Dec 2022 09:35:07 +0000 Received: (at 57460) by debbugs.gnu.org; 20 Dec 2022 09:35:02 +0000 Received: from localhost ([127.0.0.1]:43743 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7Z1Z-0003Po-EO for submit@debbugs.gnu.org; Tue, 20 Dec 2022 04:35:02 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:35623) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7Z1O-0003Ok-U5 for 57460@debbugs.gnu.org; Tue, 20 Dec 2022 04:34:51 -0500 Received: from hermia.goebel-consult.de ([87.176.134.225]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MAORp-1p1HcU1HKN-00Bri2 for <57460@debbugs.gnu.org>; Tue, 20 Dec 2022 10:34:45 +0100 Received: from thisbe.goebel-consult.de (hermia.goebel-consult.de [192.168.110.7]) by hermia.goebel-consult.de (Postfix) with ESMTP id BDC34669A4; Tue, 20 Dec 2022 10:34:23 +0100 (CET) From: Hartmut Goebel Date: Tue, 20 Dec 2022 10:34:14 +0100 Message-Id: X-Mailer: git-send-email 2.30.6 In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:t5ih020ghzFPutTDAk2J0eNwXsPC6UEGopjofTNi49bkVXVYfce sI/dgKLb/E5XiQAz5ksvf8tQ1ABbzo8JNSDTymQxLGC0d+mDEtXJMpBp48muBMbLpgeCsNR 0eMD4Q8aksPgfDwCch/FaOsXxKwwfKFgO/8M17yun0OCLRMF9lvja1luwcbZvlzrYbiWqFy tmU1MgFblCUn2lCqkGOTg== UI-OutboundReport: notjunk:1;M01:P0:CxiNzNtdGms=;QaThMoGOegf54jNF175gTBGI8fY Zq9aNTpU0JvN5fIHRQrScr42G4T3cgjD/MNp17XNfQGQRsObqGxCWzHCNRnxisZPg+Nd/BrW5 6Q2dB5KpAhm4Zz0x7jMvDZcmmJl6x51+pMMhgEJvwxWlxzzv7aZzqZ7GdS9sfcxsBntesNePY 5f4FoqWL0oUooZATarFH/QrtjBAfgWMcpyOlt/FUouhFQeM7T2TuuDi9c5naixwJx3+3DUvjh HmKAbEHFdOYNos0z0YekEwha5Mv45gTwu3lPJjjwJff/hCNNmFDc93iiWPTrRllw44QT7OE+h k5aVnwBiEgLq/Z8NpY1Kbr16h3w/S/0gwKUC0pnQw3xJxkuutjpIz0oNRZU0i6sMIZKDEV8LI GbK5t7hGS/cmmhxXEAdKq1nxcUqkGVOCOvdjgPgLcXubdZ9CUB7RscCkfi6EcmhF0L5bXqrUH LAVaIrI+iwQ4O0ywztTAIvycPyc+LMa6SxcB18/ES7QsusJi7ngeBUWSuMgPXBsAhtGOQ1GQW ZGLQIdXo98UBhvJSEJ6OwUC88tkQessDNSOrpKrEuKhbHN75YpE+grPd0aMUpSMbsq3ijU+Ne OW15j5itIIcpJXAeu6Wh/P/7LUpfXHw/XKkvuTSYDo1fyQaCq6y6f+jCYThredKG5uFu+myv2 jZrc12aSETexWYOOjFEWR9vjHBEwHuwjLvZT0bWCoA== 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/import/git.scm (latest-tag): Add #:version argument. If version is given, try to find the respective version tag. (latest-git-tag-version): Add #:version argument and pass it on to called functions. (latest-releease) Rename to 'import-release', add #:version argument and pass it on to called functions. --- guix/import/git.scm | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/guix/import/git.scm b/guix/import/git.scm index bb5ba4d97e..c15943bd7c 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,9 +147,11 @@ version corresponding to the tag, and the cdr is the name of the tag." tags) entry tag) %pre-release-rx)) @@ -169,13 +172,22 @@ repository at URL." ((null? versions->tags) (git-no-valid-tags-error)) (else - (match (last versions->tags) - ((version . tag) - (values version tag))))))) - -(define (latest-git-tag-version package) + (let ((versions (if version + (filter (match-lambda + ((candidate-version . tag) + (string=? version candidate-version))) + versions->tags) + versions->tags))) + (if (null? versions) + (values #f #f) + (match (last versions) + ((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." +tag, or #false and #false if the latest version could not be determined. +Optionally include a VERSION string to fetch a specific version." (guard (c ((or (git-no-tags-error? c) (git-no-valid-tags-error? c)) (warning (or (package-field-location package 'source) (package-location package)) @@ -193,6 +205,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 +219,14 @@ tag, or #false and #false if the latest version could not be determined." (git-reference? (origin-uri origin)))) (_ #f))) -(define (latest-git-release package) - "Return an for the latest release of PACKAGE." +(define* (import-git-release package #:key (version #f)) + "Return an for the latest release of PACKAGE. +Optionally include a VERSION string to fetch a specific version." (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 +241,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)))