From patchwork Sun Aug 28 13:18:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 42033 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 068F027BBE9; Sun, 28 Aug 2022 14:21:03 +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 2CC6127BBEA for ; Sun, 28 Aug 2022 14:21:02 +0100 (BST) Received: from localhost ([::1]:50168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSIDl-0004d3-Ap for patchwork@mira.cbaines.net; Sun, 28 Aug 2022 09:21:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSICt-0002rH-Hj for guix-patches@gnu.org; Sun, 28 Aug 2022 09:20:07 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39838) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oSICt-0002eq-0Y for guix-patches@gnu.org; Sun, 28 Aug 2022 09:20:07 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oSICs-0006yU-SR for guix-patches@gnu.org; Sun, 28 Aug 2022 09:20:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57460] [PATCH 09/20] refresh: Allow updating to a specific version (github) 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.166169275926565 (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]:57783 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSIC7-0006uK-Dh for submit@debbugs.gnu.org; Sun, 28 Aug 2022 09:19:19 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:59167) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSIC3-0006tM-Ox for 57460@debbugs.gnu.org; Sun, 28 Aug 2022 09:19:16 -0400 Received: from hermia.goebel-consult.de ([46.87.137.46]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MxVbb-1pL5fj11WT-00xqLA for <57460@debbugs.gnu.org>; Sun, 28 Aug 2022 15:19:10 +0200 Received: from lenashee.fritz.box (lenashee.goebel-consult.de [192.168.110.2]) by hermia.goebel-consult.de (Postfix) with ESMTP id E3D5E65A3C; Sun, 28 Aug 2022 15:18:55 +0200 (CEST) From: Hartmut Goebel Date: Sun, 28 Aug 2022 15:18:35 +0200 Message-Id: X-Mailer: git-send-email 2.30.4 In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:PfeJ35VcRxtNmMGHp2NMpFQT05jdZuZEz9PsfoMT40UQqOTs58h D7tyPEOzsqpdxAXkWmFzQQN5is/WJ2APfgjggUmPgw6iMsz52ErfuAebi2vV/FpySAqfoHO TKOTCiEsPZje53beSbUFvO34jx/geoTCbetR4PTh0q7crrE0zbd7zPrAc4azJ/3R9PgcFzo qQHvuhX7N26ukY9vvoLIg== X-UI-Out-Filterresults: notjunk:1;V03:K0:xjkjup0Eedo=:zQ/E1LFUlXfnYQ8dTdGmtp nEIDHRxlSWC0h630Seu9m3p3y9avXaMIYAnYiJpyKUC/JCQpZxuP7NuOAYT60q2qvilkqSQfk gUoW2pNxIwRFa5tyRRc/LzAMGZr+yFWMr7oUcaq7kq5nZelRVsH2CY1ZGNX2f+54d+ngqAC9f 9MQ5eKUNy89N6w/mJ2tQFAkPpYonJy1aisH0tXNZ+ff+i5Q9ySaAafF99HMor2k09p4L5UZHi IwF0glEVzqnre0kYADGv5CzQ/iGwswXfcqspo/7hjOd/8nF1t5aFSQZKBYCFz9pBc6qHlHqvT Kx8Ql4Q8gQ5kqtWAj2y4YV+bUXKVbMwpCuKgqFueL0dkZlR/wmN1GSf8u5CR9GPzt9+JgM63+ AHoZUgbh/6Fr9W+gGYii3Ein5/Xw51fQvHJwlg0cmnXVCj4UrJytw6bShAxoVlM24fViSeXpL B64W+cEWFFh0aq1ctdb3jtG9teWTwKC6MrfrM6cFVcdghlLcLeDbtinXCntARPEeh0RxfM6bK gmczpz6z2Z1RcQIRltlEhmy/8se2qvkmn+haNppuyTE6eoZ5NZljk1oyQp6EZw4EXZf3paU4S KMF+Yjwbeq+cqv6LrmxgVyETlkTNySEfASttd0VYu39Aqb+vHnXG0VXp0NhEhtoAaodB7clvd sps8NJIiC+Np4psgx+D5nZVCg2fuGSpYTwNbJOx/DU3x+UU9wDdn1t4QFMc6kKATp84wS0qT+ UwbSFNkoUjQeZaiRQhJX0pLBF7tr7YGgg4z+c22nW3C3A27HpvxnRzERrAY= 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/github.scm(latest-released-version): Add keyword-argument 'version'. If version is given, try to find the respective release. (latest-releease) Rename to (import-release), add keyword-argument 'version' and pass it on to latest-released-version. --- guix/import/github.scm | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/guix/import/github.scm b/guix/import/github.scm index ac6ef06eda..facdc96e24 100644 --- a/guix/import/github.scm +++ b/guix/import/github.scm @@ -249,7 +249,7 @@ 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 @@ -290,15 +290,21 @@ 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 (lambda (x) (string=? version (car x))) + 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) +(define* (import-release pkg #:key (version #f)) "Return an for the latest release of PKG." (define (github-uri uri) (match uri @@ -313,7 +319,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 +337,6 @@ releases." (name 'github) (description "Updater for GitHub packages") (pred github-package?) - (import latest-release))) + (import import-release)))