From patchwork Sat May 11 11:23:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Isaac X-Patchwork-Id: 13951 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 B32AD16F3B; Sat, 11 May 2019 12:24:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 57E3A16F15 for ; Sat, 11 May 2019 12:24:08 +0100 (BST) Received: from localhost ([127.0.0.1]:57383 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPQ6p-0002OF-4P for patchwork@mira.cbaines.net; Sat, 11 May 2019 07:24:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPQ6m-0002Nw-5u for guix-patches@gnu.org; Sat, 11 May 2019 07:24:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hPQ6l-0007WD-0E for guix-patches@gnu.org; Sat, 11 May 2019 07:24:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:54660) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hPQ6k-0007W4-T2 for guix-patches@gnu.org; Sat, 11 May 2019 07:24:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hPQ6k-0001k0-If for guix-patches@gnu.org; Sat, 11 May 2019 07:24:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#35684] import: github: Sort releases before picking the latest one. Resent-From: Arun Isaac Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 11 May 2019 11:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 35684 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 35684@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.15575738236659 (code B ref -1); Sat, 11 May 2019 11:24:02 +0000 Received: (at submit) by debbugs.gnu.org; 11 May 2019 11:23:43 +0000 Received: from localhost ([127.0.0.1]:39971 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hPQ6R-0001jL-9p for submit@debbugs.gnu.org; Sat, 11 May 2019 07:23:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52871) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hPQ6O-0001j7-7i for submit@debbugs.gnu.org; Sat, 11 May 2019 07:23:41 -0400 Received: from lists.gnu.org ([209.51.188.17]:45477) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hPQ6J-00073f-1N for submit@debbugs.gnu.org; Sat, 11 May 2019 07:23:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPQ6H-0002JH-Ll for guix-patches@gnu.org; Sat, 11 May 2019 07:23:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hPQ6G-00071m-Ja for guix-patches@gnu.org; Sat, 11 May 2019 07:23:33 -0400 Received: from mugam.systemreboot.net ([139.59.75.54]:48632) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hPQ6F-0006uv-GD for guix-patches@gnu.org; Sat, 11 May 2019 07:23:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=systemreboot.net; s=default; h=Content-Type:MIME-Version:Message-ID:Date: Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=GvIH2PDrXNCnoW9iKHsYC+gn2XclCzzArwsDSymBib0=; b=AF94KYbcQOOnPwk0I7PyOZfjh+ z9I86P1s5fPwh7hD5LYg8WyjBdcIdrCqyFJCt8XFWdnzJXzbKX6mKZLev5EG23vfh3/9LYArgrUNY yNVIV0RHkj2NcgxEfD08e2Eiv/ZtxreVFQW/8et7c7z2oSZVo42j1scJKBclVGZ0te6k=; Received: from [49.206.13.189] (helo=steel) by systemreboot.net with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1hPQ6A-0001vZ-WE for guix-patches@gnu.org; Sat, 11 May 2019 16:53:27 +0530 From: Arun Isaac Date: Sat, 11 May 2019 16:53:21 +0530 Message-ID: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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 Prior to this, for some packages (e.g., osc in (gnu packages build-tools)), `guix refresh' could not find the latest version correctly. From 33f42ea8a33c6e502062708336a5ab8be871c92b Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sat, 11 May 2019 16:40:38 +0530 Subject: [PATCH] import: github: Sort releases before picking the latest one. * guix/import/github.scm (latest-released-version): Sort releases before picking the first one as the latest. --- guix/import/github.scm | 55 ++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/guix/import/github.scm b/guix/import/github.scm index 4d12339204..a8af318bc8 100644 --- a/guix/import/github.scm +++ b/guix/import/github.scm @@ -183,32 +183,35 @@ API when using a GitHub token") API. This may be fixed by using an access token and setting the environment variable GUIX_GITHUB_TOKEN, for instance one procured from https://github.com/settings/tokens")) - (any - (lambda (release) - (let ((tag (or (hash-ref release "tag_name") ;a "release" - (hash-ref release "name"))) ;a tag - (name-length (string-length package-name))) - (cond - ;; some tags include the name of the package e.g. "fdupes-1.51" - ;; so remove these - ((and (< name-length (string-length tag)) - (string=? (string-append package-name "-") - (substring tag 0 (+ name-length 1)))) - (substring tag (+ name-length 1))) - ;; some tags start with a "v" e.g. "v0.25.0" - ;; where some are just the version number - ((string-prefix? "v" tag) - (substring tag 1)) - ;; Finally, reject tags that don't start with a digit: - ;; they may not represent a release. - ((and (not (string-null? tag)) - (char-set-contains? char-set:digit - (string-ref tag 0))) - tag) - (else #f)))) - (match (remove pre-release? json) - (() json) ; keep everything - (releases releases)))))) + (first + (sort + (filter-map + (lambda (release) + (let ((tag (or (hash-ref release "tag_name") ;a "release" + (hash-ref release "name"))) ;a tag + (name-length (string-length package-name))) + (cond + ;; some tags include the name of the package e.g. "fdupes-1.51" + ;; so remove these + ((and (< name-length (string-length tag)) + (string=? (string-append package-name "-") + (substring tag 0 (+ name-length 1)))) + (substring tag (+ name-length 1))) + ;; some tags start with a "v" e.g. "v0.25.0" + ;; where some are just the version number + ((string-prefix? "v" tag) + (substring tag 1)) + ;; Finally, reject tags that don't start with a digit: + ;; they may not represent a release. + ((and (not (string-null? tag)) + (char-set-contains? char-set:digit + (string-ref tag 0))) + tag) + (else #f)))) + (match (remove pre-release? json) + (() json) ; keep everything + (releases releases))) + version>?))))) (define (latest-release pkg) "Return an for the latest release of PKG." -- 2.21.0