diff options
Diffstat (limited to 'guix/import/github.scm')
-rw-r--r-- | guix/import/github.scm | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/guix/import/github.scm b/guix/import/github.scm index 7136e7a34f..888b148ffb 100644 --- a/guix/import/github.scm +++ b/guix/import/github.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com> -;;; Copyright © 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2018 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2019 Arun Isaac <arunisaac@systemreboot.net> ;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il> @@ -26,10 +26,13 @@ #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (guix utils) + #:use-module (guix i18n) + #:use-module (guix diagnostics) #: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 (json) #:use-module (guix packages) #:use-module (guix upstream) #:use-module (guix http-client) @@ -90,20 +93,23 @@ false if none is recognized" (#t #f))) ; Some URLs are not recognised. #f)) - (let ((source-uri (and=> (package-source old-package) origin-uri)) - (fetch-method (and=> (package-source old-package) origin-method))) - (cond - ((eq? fetch-method download:url-fetch) - (match source-uri - ((? string?) - (updated-url source-uri)) - ((source-uri ...) - (find updated-url source-uri)))) - ((and (eq? fetch-method download:git-fetch) - (string-prefix? "https://github.com/" - (download:git-reference-url source-uri))) - (download:git-reference-url source-uri)) - (else #f)))) + (match (package-source old-package) + ((? origin? origin) + (let ((source-uri (origin-uri origin)) + (fetch-method (origin-method origin))) + (cond + ((eq? fetch-method download:url-fetch) + (match source-uri + ((? string?) + (updated-url source-uri)) + ((source-uri ...) + (find updated-url source-uri)))) + ((and (eq? fetch-method download:git-fetch) + (string-prefix? "https://github.com/" + (download:git-reference-url source-uri))) + (download:git-reference-url source-uri)) + (else #f)))) + (_ #f))) (define (github-package? package) "Return true if PACKAGE is a package from GitHub, else false." @@ -159,12 +165,20 @@ empty list." `((Authorization . ,(string-append "token " (%github-token)))) '()))) - (match (json-fetch release-url #:headers headers) - (#() - ;; We got the empty list, presumably because the user didn't use GitHub's - ;; "release" mechanism, but hopefully they did use Git tags. - (json-fetch tag-url #:headers headers)) - (x x))) + (guard (c ((and (http-get-error? c) + (= 404 (http-get-error-code c))) + (warning (G_ "~a is unreachable (~a)~%") + release-url (http-get-error-code c)) + '#())) ;return an empty release set + (let* ((port (http-fetch release-url #:headers headers)) + (result (json->scm port))) + (close-port port) + (match result + (#() + ;; We got the empty list, presumably because the user didn't use GitHub's + ;; "release" mechanism, but hopefully they did use Git tags. + (json-fetch tag-url #:headers headers)) + (x x))))) (define (latest-released-version url package-name) "Return a string of the newest released version name given a string URL like |