[bug#33801] import: github: Support source URIs that redirect to GitHub

Message ID cu7tvih6jmn.fsf@systemreboot.net
State Accepted
Headers show
Series [bug#33801] import: github: Support source URIs that redirect to GitHub | expand

Checks

Context Check Description
cbaines/package builds pending In Cuirass
cbaines/package builds pending In Cuirass
cbaines/package builds pending In Cuirass
cbaines/package builds pending In Cuirass
cbaines/applying patch fail Apply failed

Commit Message

Arun Isaac Jan. 10, 2019, 7:45 a.m. UTC
>> gnu/packages/lisp.scm:3806:7: In procedure inputs:
>> error: xclip: unbound variable
>
> Ouch.  This is fixed by 804b9b18ac9188ffb6c6891cbb9241c6a80ed7c8.  I
> think we were just lucky it didn’t bite before.

Ok.

> You can recheck your patch and push it I guess.

Please find attached an updated patch complete with the test case.

Comments

Ludovic Courtès Jan. 10, 2019, 8:52 a.m. UTC | #1
Hello,

Arun Isaac <arunisaac@systemreboot.net> skribis:

>> You can recheck your patch and push it I guess.
>
> Please find attached an updated patch complete with the test case.
>
> From 2711c58b8d713bf87e2a01d21a4bc6c77ccc7b7d Mon Sep 17 00:00:00 2001
> From: Arun Isaac <arunisaac@systemreboot.net>
> Date: Mon, 7 Jan 2019 23:11:58 +0530
> Subject: [PATCH] guix: lint: Warn only if GitHub URI is not same as the
>  package URI.
>
> * guix/scripts/lint.scm (check-github-url): Warn only if the GitHub URI
> obtained after following redirects is not same as the original URI.
> * tests/lint.scm ("github-url: already the correct github url"): New test.

Alright, please push!

Thank you,
Ludo’.
Arun Isaac Jan. 10, 2019, 10:12 a.m. UTC | #2
> Alright, please push!

Done!

Patch

From 2711c58b8d713bf87e2a01d21a4bc6c77ccc7b7d Mon Sep 17 00:00:00 2001
From: Arun Isaac <arunisaac@systemreboot.net>
Date: Mon, 7 Jan 2019 23:11:58 +0530
Subject: [PATCH] guix: lint: Warn only if GitHub URI is not same as the
 package URI.

* guix/scripts/lint.scm (check-github-url): Warn only if the GitHub URI
obtained after following redirects is not same as the original URI.
* tests/lint.scm ("github-url: already the correct github url"): New test.
---
 guix/scripts/lint.scm | 11 ++++++-----
 tests/lint.scm        | 11 ++++++++++-
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index 9acec4857..0f315a935 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -8,7 +8,7 @@ 
 ;;; Copyright © 2017 Alex Kost <alezost@gmail.com>
 ;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
-;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2018, 2019 Arun Isaac <arunisaac@systemreboot.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -820,10 +820,11 @@  descriptions maintained upstream."
        (lambda (uri)
          (and=> (follow-redirects-to-github uri)
                 (lambda (github-uri)
-                  (emit-warning
-                   package
-                   (format #f (G_ "URL should be '~a'") github-uri)
-                   'source))))
+                  (unless (string=? github-uri uri)
+                    (emit-warning
+                     package
+                     (format #f (G_ "URL should be '~a'") github-uri)
+                     'source)))))
        (origin-uris origin)))))
 
 (define (check-derivation package)
diff --git a/tests/lint.scm b/tests/lint.scm
index fe12bebd8..521e9fb40 100644
--- a/tests/lint.scm
+++ b/tests/lint.scm
@@ -775,7 +775,16 @@ 
                                       (method url-fetch)
                                       (uri (%local-url))
                                       (sha256 %null-sha256))))))))))
-     github-url)))
+     github-url))
+  (test-assert "github-url: already the correct github url"
+    (string-null?
+     (with-warnings
+       (check-github-url
+        (dummy-package "x" (source
+                            (origin
+                              (method url-fetch)
+                              (uri github-url)
+                              (sha256 %null-sha256)))))))))
 
 (test-assert "cve"
   (mock ((guix scripts lint) package-vulnerabilities (const '()))
-- 
2.19.2