From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZoGs-0003gb-Dd for guix-patches@gnu.org; Wed, 19 Dec 2018 21:41:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZoGl-0001cD-WD for guix-patches@gnu.org; Wed, 19 Dec 2018 21:41:07 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:51084) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gZoGk-0001aD-35 for guix-patches@gnu.org; Wed, 19 Dec 2018 21:41:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gZoGj-00066c-RR for guix-patches@gnu.org; Wed, 19 Dec 2018 21:41:01 -0500 Subject: [bug#33809] [PATCH] refresh: github: updates for origins using 'git-fetch'. Resent-Message-ID: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZoFn-0002sG-D2 for guix-patches@gnu.org; Wed, 19 Dec 2018 21:40:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZoFk-0000LJ-4P for guix-patches@gnu.org; Wed, 19 Dec 2018 21:40:03 -0500 Received: from mail.onyx.syn-alias.com ([206.152.134.66]:52429 helo=smtp.centurylink.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZoFj-0000IX-Rl for guix-patches@gnu.org; Wed, 19 Dec 2018 21:40:00 -0500 From: ericbavier@centurylink.net Date: Wed, 19 Dec 2018 20:39:54 -0600 Message-Id: <20181220023954.22913-1-ericbavier@centurylink.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 33809@debbugs.gnu.org Cc: Eric Bavier From: Eric Bavier * guix/import/github.scm (updated-github-url): Respond with the repository url for the 'git-fetch' fetch method. (github-package=3F): Simplify boolean expression. (github-repository, github-user-slash-repository): Strip trailing ".git" from project if present. (latest-release): Recognize a 'git-reference'. --- Hello Guix, With our increasing adoption of git checkouts from github, for reproducibility reasons, I thought it would be nice if our github updater could find updates for package origins that use `git-fetch`. This patch brings the github updater coverage up from 9.5% to 15.9%. At the time of this writing, the previous updater finds 254 updates, and with this patch finds 385! :) guix/import/github.scm | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/guix/import/github.scm b/guix/import/github.scm index af9f56e1d..ad662e7b0 100644 --- a/guix/import/github.scm +++ b/guix/import/github.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2016 Ben Woodcroft ;;; Copyright =C2=A9 2017, 2018 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2018 Eric Bavier ;;; ;;; This file is part of GNU Guix. ;;; @@ -24,6 +25,7 @@ #:use-module (srfi srfi-34) #:use-module (guix utils) #:use-module ((guix download) #:prefix download:) + #:use-module ((guix git-download) #:prefix download:) #:use-module (guix import utils) #:use-module (guix import json) #:use-module (guix packages) @@ -52,6 +54,7 @@ false if none is recognized" (github-user-slash-repository url))) (repo (github-repository url))) (cond + ((string-suffix=3F ".git" url) url) ((string-suffix=3F (string-append "/tarball/v" version) url) (string-append prefix "/tarball/v" new-version)) ((string-suffix=3F (string-append "/tarball/" version) url) @@ -86,26 +89,29 @@ false if none is recognized" (#t #f))) ; Some URLs are not recognised. #f)) - (let ((source-url (and=3D> (package-source old-package) origin-uri)) + (let ((source-uri (and=3D> (package-source old-package) origin-uri)) (fetch-method (and=3D> (package-source old-package) origin-method))) - (if (eq=3F fetch-method download:url-fetch) - (match source-url - ((=3F string=3F) - (updated-url source-url)) - ((source-url ...) - (find updated-url source-url))) - #f))) + (cond + ((eq=3F fetch-method download:url-fetch) + (match source-uri + ((=3F string=3F) + (updated-url source-uri)) + ((source-uri ...) + (find updated-url source-uri)))) + ((eq=3F fetch-method download:git-fetch) + (updated-url (download:git-reference-url source-uri))) + (else #f)))) (define (github-package=3F package) "Return true if PACKAGE is a package from GitHub, else false." - (not (eq=3F #f (updated-github-url package "dummy")))) + (->bool (updated-github-url package "dummy"))) (define (github-repository url) "Return a string e.g. bedtools2 of the name of the repository, from a string URL of the form 'https://github.com/arq5x/bedtools2/archive/v2.24.0.tar.gz'" (match (string-split (uri-path (string->uri url)) #\/) ((_ owner project . rest) - (string-append project)))) + (string-append (basename project ".git"))))) (define (github-user-slash-repository url) "Return a string e.g. arq5x/bedtools2 of the owner and the name of the @@ -113,7 +119,7 @@ repository separated by a forward slash, from a string URL of the form 'https://github.com/arq5x/bedtools2/archive/v2.24.0.tar.gz'" (match (string-split (uri-path (string->uri url)) #\/) ((_ owner project . rest) - (string-append owner "/" project)))) + (string-append owner "/" (basename project ".git"))))) (define %github-token ;; Token to be passed to Github.com to avoid the 60-request per hour @@ -213,6 +219,8 @@ https://github.com/settings/tokens")) (match (origin-uri origin) ((=3F string=3F url) url) ;surely a github.com URL + ((=3F download:git-reference=3F ref) + (download:git-reference-url ref)) ((urls ...) (find (cut string-contains <> "github.com") urls)))) -- 2.20.1