diff mbox series

[bug#39430] Use CRAN’s canonical URL as home-page

Message ID 20200205074933.GH2917@zpidnp36
State Accepted
Delegated to: Christopher Baines
Headers show
Series [bug#39430] Use CRAN’s canonical URL as home-page | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job

Commit Message

Lars-Dominik Braun Feb. 5, 2020, 7:49 a.m. UTC
Hi,

I noticed for packages not specifying any URL the CRAN importer emits home-page
URLs like https://cran.r-project.org/web/packages/<package> (without trailing
slash). These are permanent redirects, thus the linter complains about them.
One option would be adding a trailing slash or use the canonical URL, as
provided by CRAN (on the bottom of the description page). The attached patch
does the latter.

Lars

Comments

Christopher Baines Dec. 13, 2020, 1:17 p.m. UTC | #1
Lars-Dominik Braun <ldb@leibniz-psychology.org> writes:

> I noticed for packages not specifying any URL the CRAN importer emits home-page
> URLs like https://cran.r-project.org/web/packages/<package> (without trailing
> slash). These are permanent redirects, thus the linter complains about them.
> One option would be adding a trailing slash or use the canonical URL, as
> provided by CRAN (on the bottom of the description page). The attached patch
> does the latter.

Hi,

Sorry for the delay in following up on this.

I gave this patch a try, testing using gProfileR as just a random
package I picked.

So, my take on this is that the canonical URLs still redirect, but using
a 303 redirect, which the linter doesn't complain about. Given I see [1]
on the page, I guess it makes sense to use these URLs.

1: Please use the canonical form https://CRAN.R-project.org/package=gProfileR to link to this page.

I'll leave it a day or two for others to comment, as I'm not
particularly familiar with CRAN, but I'm happy to merge this.

Thanks,

Chris
Christopher Baines Dec. 15, 2020, 10:35 p.m. UTC | #2
Christopher Baines <mail@cbaines.net> writes:

> Lars-Dominik Braun <ldb@leibniz-psychology.org> writes:
>
>> I noticed for packages not specifying any URL the CRAN importer emits home-page
>> URLs like https://cran.r-project.org/web/packages/<package> (without trailing
>> slash). These are permanent redirects, thus the linter complains about them.
>> One option would be adding a trailing slash or use the canonical URL, as
>> provided by CRAN (on the bottom of the description page). The attached patch
>> does the latter.
>
> Hi,
>
> Sorry for the delay in following up on this.
>
> I gave this patch a try, testing using gProfileR as just a random
> package I picked.
>
> So, my take on this is that the canonical URLs still redirect, but using
> a 303 redirect, which the linter doesn't complain about. Given I see [1]
> on the page, I guess it makes sense to use these URLs.
>
> 1: Please use the canonical form https://CRAN.R-project.org/package=gProfileR to link to this page.
>
> I'll leave it a day or two for others to comment, as I'm not
> particularly familiar with CRAN, but I'm happy to merge this.

I've gone ahead and pushed this as
f14bb29defb36051039e977ba3791b542d90578a. I tweaked one of the variable
names.

Thanks again,

Chris
diff mbox series

Patch

From 01a43735fe5b2ee5c34431d9e5109e3718e7612b Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <ldb@leibniz-psychology.org>
Date: Wed, 5 Feb 2020 08:26:08 +0100
Subject: [PATCH] =?UTF-8?q?import:=20cran:=20Use=20CRAN=E2=80=99s=20canoni?=
 =?UTF-8?q?cal=20URL=20as=20home-page?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* guix/import/cran.scm (%cran-canonical-url): New variable.
(description->package): Construct home-page using canonical URL.
---
 guix/import/cran.scm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/guix/import/cran.scm b/guix/import/cran.scm
index bcb37ed250..9f1214324c 100644
--- a/guix/import/cran.scm
+++ b/guix/import/cran.scm
@@ -134,6 +134,7 @@  package definition."
      `((,type (,'quasiquote ,(format-inputs package-inputs)))))))
 
 (define %cran-url "https://cran.r-project.org/web/packages/")
+(define %cran-canonical-url "https://cran.r-project.org/package=")
 (define %bioconductor-url "https://bioconductor.org/packages/")
 
 ;; The latest Bioconductor release is 3.10.  Bioconductor packages should be
@@ -402,6 +403,10 @@  from the alist META, which was derived from the R package's DESCRIPTION file."
                        ((cran)         %cran-url)
                        ((bioconductor) %bioconductor-url)
                        ((git)          #f)))
+         (canonical-url   (case repository
+                            ((cran)         %cran-canonical-url)
+                            ((bioconductor) %bioconductor-url)
+                            ((git)          #f)))
          (uri-helper (case repository
                        ((cran)         cran-uri)
                        ((bioconductor) bioconductor-uri)
@@ -415,7 +420,7 @@  from the alist META, which was derived from the R package's DESCRIPTION file."
                        ((git) (assoc-ref meta 'git))
                        (else (match (listify meta "URL")
                                ((url rest ...) url)
-                               (_ (string-append base-url name))))))
+                               (_ (string-append canonical-url name))))))
          (source-url (case repository
                        ((git) (assoc-ref meta 'git))
                        (else
-- 
2.20.1