From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id IMK3AZmHoWM7AQAAbAwnHQ (envelope-from ) for ; Tue, 20 Dec 2022 10:59:53 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id sH/ZAJmHoWNLDQEAG6o9tA (envelope-from ) for ; Tue, 20 Dec 2022 10:59:53 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A82D71825E for ; Tue, 20 Dec 2022 10:59:52 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7Z2W-0004tQ-FZ; Tue, 20 Dec 2022 04:36:00 -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-0004g8-Ma 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-0002vy-Cp 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 1p7Z1g-0003Rn-8v for guix-patches@gnu.org; Tue, 20 Dec 2022 04:35:08 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#57460] [PATCH v3 10/18] import: github: 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:08 +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.167152890213157 (code B ref 57460); Tue, 20 Dec 2022 09:35:08 +0000 Received: (at 57460) by debbugs.gnu.org; 20 Dec 2022 09:35:02 +0000 Received: from localhost ([127.0.0.1]:43745 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7Z1a-0003Px-1u for submit@debbugs.gnu.org; Tue, 20 Dec 2022 04:35:02 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:45549) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7Z1S-0003Oq-EQ for 57460@debbugs.gnu.org; Tue, 20 Dec 2022 04:34:55 -0500 Received: from hermia.goebel-consult.de ([87.176.134.225]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MXotA-1pOCDU3QPU-00YBZ7 for <57460@debbugs.gnu.org>; Tue, 20 Dec 2022 10:34:48 +0100 Received: from thisbe.goebel-consult.de (hermia.goebel-consult.de [192.168.110.7]) by hermia.goebel-consult.de (Postfix) with ESMTP id E2401669A5; Tue, 20 Dec 2022 10:34:23 +0100 (CET) From: Hartmut Goebel Date: Tue, 20 Dec 2022 10:34:15 +0100 Message-Id: <9344624489973aad01dfb6f2ed3c072e29964610.1671527962.git.h.goebel@crazy-compilers.com> X-Mailer: git-send-email 2.30.6 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:hljYhqfObiDFw5vetJdqSqD7DLOW8UN2Z2JGeiaNoWe4xXVD4/t 5sNaIBYoEUE+sXq4LeDoZTIBrT1RahUtA5lZQMcDtO7cqMiuSbA7BaDKy8dvjo7WIyuNMtf 15zMbKfN5eOtisVXwDllN4o3Z5vROJMIHkXAoo9sqmB4XGy2ht+wrfx52QOAuk6FTiWdscz r7Jj7MAxOZdIzn5NNcB3Q== UI-OutboundReport: notjunk:1;M01:P0:9ijiATMDvQk=;uQDUhcnE21Tw1EXWePdeZiqCdsV JVQgtSeBl31xsaMbORSbhmHkyUfpoKY1mha5F90xIB3mHt2IgTIzZKr8yanIrX+nWd1ZtxjGr dlG06Wm0CM6N6HU8fMOd7Ib0XnKoBuzzdYsKPHnT6eyUnlGT4CwWjmYoDKWoT5oYal6+Cm/4S kh5PNjp4+jQGvi4UbDFCYbt6Z4nn33uEnls0VtrCr8ljmJoHyDpq5VcciOzCtauhSjOt1mgZ4 XTdj5MEw29emDG29ZybkShiEusoc6CTnzyGzNSyYZ4YJaAoI5b/sa1HT7GLBBf314vY2TVRbD lc/oRaYE1HK7N9/XttkU1EMH5NyHEL2NlhXVIwwVn/LIILeZxTH5Y1fPl5Qzaz1/MzqMWo47p qfllwTVi/Uu9bm2DNI7gogHIDB4T6l/2mTegMHqyKyvvo1C/LWp9gjRNr5o46+vtg9HrUHAW6 t4/o7LPeqf6+X0oTFEy/eEIlQ6ynM42fA6toOxXQwH55lvo7aetLmFQvGGynoIzhBOMqvnKTj KgDQuVEmiEE6a+lFPVD+TH8eQ/eFDOciEwMHJfxIZ4ifuCfjX+YBEGPBpi5qA0n4p5kApEfZ4 LDkVr7o9DAEqbWW7UjJU2ki6rJnm74FP6cfIz5d/KCbWiTFNMyHjG2aPL+CUFi8I1goTMFuAr MzopjTOfoeCc4zjzEii32tr/E4Hclr/Be53nOw5P1g== 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+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1671530392; a=rsa-sha256; cv=none; b=dUypt2M8yBH2fOtHFixqcw0lz2aNU+grhqffhfzmw8FzvAEQx6JKg/IYresSCR5NYV/Qwh yYzMW+1a2g5NeJ4R+Ah0qmuRXxwqO95bBBqCxRzDUx4o1CYVLK0VOazO0Ue6eo6y/iCjRn iSpvcrfaUoFJcj1POc/+jPGLNZGFYpbH9pMq276t2wZCmCXK8BJhP8JlR9yOO6lt+VL+zx bQ5/VTiqQg/J12mNLjdoFdagNhd6WjCWCIkOz/nvfZB91peskIWYSWP2KKOadN6D9Ea6/y WpLTdzzwOk1Vl9gkxisb5VPRE7ulbsDtJ0pTsbxYzoaU4H+AyRVKE2HGyaNmDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1671530392; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=h7lSLj0uC0xGmmBVUg0Z+imRO9xyyZQg1MBaL5oePvw=; b=bfjtDB7Mttl2iK2c3Jp0PZHTLCb4XI9s7/uMN2RT3pVMwPe0xNVlEYdAD0mAFFl34Oo46b Lf9KPGP3qID9N2hMW8saU0+DgndCby2OFV/oUq/DPcrIbe+wVMmNJL31s3jNpsJW4dS3gW 5/V86a9+9LuJfqY1CzrqlFICe8tvDN3MJN+qv/vsvndaw/4g2oRiqFlRiv0Tg0uVU8KUrw 5GrdtPCnzcWL08ht7U1VPGoD24aGFLa98DM4SC8iKEz3SLuUB5VVzNUI1rNcs2S3fhosHx UjIs4mL9HICQuNdvg5mOREQCcN+6F3Z4lxSlIbhPqzIW/aihD+vk9mg/c5BvjQ== Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -1.49 X-Spam-Score: -1.49 X-Migadu-Queue-Id: A82D71825E X-TUID: jnpiiSm2W2XE * guix/import/github.scm (latest-released-version): Add #:version argument. If version is given, try to find the respective release. (latest-releease) Rename to 'import-release', add #:version argument and pass it on to 'latest-released-version'. --- guix/import/github.scm | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/guix/import/github.scm b/guix/import/github.scm index ac6ef06eda..a1bda5ec43 100644 --- a/guix/import/github.scm +++ b/guix/import/github.scm @@ -249,11 +249,13 @@ Alternatively, you can wait until your rate limit is reset, or use the #:headers headers))) (x x))))))))) -(define (latest-released-version url package-name) +(define* (latest-released-version url package-name #:key (version #f)) "Return the newest released version and its tag given a string URL like 'https://github.com/arq5x/bedtools2/archive/v2.24.0.tar.gz' and the name of the package e.g. 'bedtools2'. Return #f (two values) if there are no -releases." +releases. + +Optionally include a VERSION string to fetch a specific version." (define (pre-release? x) (assoc-ref x "prerelease")) @@ -290,16 +292,25 @@ releases." (match (and=> (fetch-releases-or-tags url) vector->list) (#f (values #f #f)) (json - (match (sort (filter-map release->version - (match (remove pre-release? json) - (() json) ; keep everything - (releases releases))) - (lambda (x y) (version>? (car x) (car y)))) + (let ((releases (filter-map release->version + (match (remove pre-release? json) + (() json) ; keep everything + (releases releases))))) + (match (if version + ;; Find matching release version. + (filter (match-lambda + ((candidate-version . tag) + (string=? version candidate-version))) + releases) + ;; Sort releases descending. + (sort releases + (lambda (x y) (version>? (car x) (car y))))) (((latest-version . tag) . _) (values latest-version tag)) - (() (values #f #f)))))) + (() (values #f #f))))))) -(define (latest-release pkg) - "Return an for the latest release of PKG." +(define* (import-release pkg #:key (version #f)) + "Return an for the latest release of PKG. +Optionally include a VERSION string to fetch a specific version." (define (github-uri uri) (match uri ((? string? url) @@ -313,7 +324,8 @@ releases." (source-uri (github-uri original-uri)) (name (package-name pkg)) (newest-version version-tag - (latest-released-version source-uri name))) + (latest-released-version source-uri name + #:version version))) (if newest-version (upstream-source (package name) @@ -330,6 +342,6 @@ releases." (name 'github) (description "Updater for GitHub packages") (pred github-package?) - (import latest-release))) + (import import-release))) -- 2.30.6