From c10526672e515f07c92dc447bbc592808f67238e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 12 Jul 2020 22:41:09 +0200 Subject: lint: source: Validate URLs of Git references. Until now the 'source' checker would look at URL for 'url-fetch' origins but not for 'git-fetch' origins. * guix/lint.scm (check-source): Add case for 'git-reference?'. * tests/lint.scm ("source, git-reference: 301 -> 200"): New test. --- guix/lint.scm | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'guix') diff --git a/guix/lint.scm b/guix/lint.scm index 445c06f8f4..a550caa237 100644 --- a/guix/lint.scm +++ b/guix/lint.scm @@ -793,27 +793,32 @@ descriptions maintained upstream." (loop rest (cons warning warnings)))))))) (let ((origin (package-source package))) - (if (and (origin? origin) - (eqv? (origin-method origin) url-fetch)) - (let* ((uris (append-map (cut maybe-expand-mirrors <> %mirrors) - (map string->uri (origin-uris origin)))) - (warnings (warnings-for-uris uris))) - - ;; Just make sure that at least one of the URIs is valid. - (if (= (length uris) (length warnings)) - ;; When everything fails, report all of WARNINGS, otherwise don't - ;; report anything. - ;; - ;; XXX: Ideally we'd still allow warnings to be raised if *some* - ;; URIs are unreachable, but distinguish that from the error case - ;; where *all* the URIs are unreachable. - (cons* - (make-warning package - (G_ "all the source URIs are unreachable:") - #:field 'source) - warnings) - '())) - '()))) + (if (origin? origin) + (cond + ((eq? (origin-method origin) url-fetch) + (let* ((uris (append-map (cut maybe-expand-mirrors <> %mirrors) + (map string->uri (origin-uris origin)))) + (warnings (warnings-for-uris uris))) + + ;; Just make sure that at least one of the URIs is valid. + (if (= (length uris) (length warnings)) + ;; When everything fails, report all of WARNINGS, otherwise don't + ;; report anything. + ;; + ;; XXX: Ideally we'd still allow warnings to be raised if *some* + ;; URIs are unreachable, but distinguish that from the error case + ;; where *all* the URIs are unreachable. + (cons* + (make-warning package + (G_ "all the source URIs are unreachable:") + #:field 'source) + warnings) + '()))) + ((git-reference? (origin-uri origin)) + (warnings-for-uris + (list (string->uri (git-reference-url (origin-uri origin)))))) + (else + '()))))) (define (check-source-file-name package) "Emit a warning if PACKAGE's origin has no meaningful file name." -- cgit v1.2.3