From debbugs-submit-bounces@debbugs.gnu.org Sat May 11 07:23:43 2019 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,URIBL_BLOCKED autolearn=disabled version=3.3.2 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 To: guix-patches@gnu.org Subject: import: github: Sort releases before picking the latest one. Date: Sat, 11 May 2019 16:53:21 +0530 Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 139.59.75.54 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Prior to this, for some packages (e.g., osc in (gnu packages build-tools)), `guix refresh' could not find the latest version correctly. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-import-github-Sort-releases-before-picking-the-lates.patch Content-Transfer-Encoding: quoted-printable From=2033f42ea8a33c6e502062708336a5ab8be871c92b 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 on= e. * guix/import/github.scm (latest-released-version): Sort releases before picking the first one as the latest. =2D-- 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 =2D-- 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")) =2D (any =2D (lambda (release) =2D (let ((tag (or (hash-ref release "tag_name") ;a "release" =2D (hash-ref release "name"))) ;a tag =2D (name-length (string-length package-name))) =2D (cond =2D ;; some tags include the name of the package e.g. "fdupes-= 1.51" =2D ;; so remove these =2D ((and (< name-length (string-length tag)) =2D (string=3D? (string-append package-name "-") =2D (substring tag 0 (+ name-length 1)))) =2D (substring tag (+ name-length 1))) =2D ;; some tags start with a "v" e.g. "v0.25.0" =2D ;; where some are just the version number =2D ((string-prefix? "v" tag) =2D (substring tag 1)) =2D ;; Finally, reject tags that don't start with a digit: =2D ;; they may not represent a release. =2D ((and (not (string-null? tag)) =2D (char-set-contains? char-set:digit =2D (string-ref tag 0))) =2D tag) =2D (else #f)))) =2D (match (remove pre-release? json) =2D (() json) ; keep everything =2D (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=3D? (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>?))))) =20 (define (latest-release pkg) "Return an for the latest release of PKG." =2D-=20 2.21.0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEf3MDQ/Lwnzx3v3nTLiXui2GAK7MFAlzWsKoACgkQLiXui2GA K7NdjwgAqQ/YarcqTl9yArKcCvLRCXq0Ta/Y3ZDRf2qz2mTRs/3bPivIQEG+5oJf BPnlrSA6NQIrku7tM/ryRtNQGag/O8yUEdi496vU7mxa1X6jJlxXYaLOKGat7wp6 ZN6QrjKhx5oUlYUXEtuhRHgLUUlQvTQ95oFhVvP8jf8lC0E3va115Mt3KXMLTm3p easLET250+FnP5P3Q6+L4XtJ0Wwro7Y6UKnpCeUgI9DcZ0FvVYrbMSbx4wTtf1OT 872RXgiB5JCLxXaqUP+G+96U1+sfZWfnu4tX+QYljQ1wNSMUwd9DZ5QlytvHiOQj NtkRv8W24JRwrPVphqCEPcrJ7WkqNg== =vJPD -----END PGP SIGNATURE----- --==-=-=--