Message ID | 20220126104139.17df3cbb@ens-lyon.fr |
---|---|
State | Accepted |
Headers | show |
Series | [bug#53548] Harden beautify-description | expand |
Context | Check | Description |
---|---|---|
cbaines/comparison | success | View comparision |
cbaines/git branch | success | View Git branch |
cbaines/applying patch | fail | View Laminar job |
cbaines/issue | success | View issue |
Hi Alice, Alice BRENON <alice.brenon@ens-lyon.fr> skribis: > Missing metadata in packages used to break their imports, at least for > opam packages, until this was fixed by Julien in > 24aa7b3c21309b63cc6e8e18d6417d2cddccf6c6. When Xinglu improved the > output of descriptions in 155fc235b5e1b41b4665c782365dd2bf11beae9c, it > made the imports break again in the case when the `description` field > is missing and Julien's fix applies, returning #f in `metadata-ref` > instead of crashing. Trouble is: beautify-description expects its > description argument to be a string and will crash if this assumption > isn't met (when calling the `string-prefix?` predicate). Thanks for explaining! Some comments: > From 22f0523ef3599b45af9448bd4f31f7b8f8ce6af2 Mon Sep 17 00:00:00 2001 > From: Alice BRENON <alice.brenon@ens-lyon.fr> > Date: Wed, 26 Jan 2022 09:27:12 +0100 > Subject: [PATCH] guix: import: Harden beautify-description. > > * guix/import/utils.scm (beautify-description): Handle non-string > arguments. > * guix/import/opam.scm: [use-modules] Make imports explicit for module > (guix import utils). [...] > #:use-module ((guix utils) #:select (cache-directory > version>? > call-with-temporary-output-file)) > - #:use-module (guix import utils) > + #:use-module ((guix import utils) #:select (beautify-description > + guix-hash-url > + recursive-import > + spdx-string->license > + url-fetch)) It can’t hurt. > + ((not (string? description)) > + (let ((home-url "https://guix.gnu.org/") > + (doc-path "fr/manual/devel/en/html_node/") > + (page > + "Synopses-and-Descriptions.html#Synopses-and-Descriptions")) > + (string-append > + "Please fill in the description of your package before " > + "submitting ! See " > + home-url doc-path page))) I’d avoid the URL and maybe make the string translatable, like so: (G_ "This package lacks a description … Run \"info '(guix) Synopses and Descriptions'\" for more information.") … where ‘G_’ comes from (guix i18n). WDYT? This looks like a welcome improvement to me. Thanks! Ludo’.
From 22f0523ef3599b45af9448bd4f31f7b8f8ce6af2 Mon Sep 17 00:00:00 2001 From: Alice BRENON <alice.brenon@ens-lyon.fr> Date: Wed, 26 Jan 2022 09:27:12 +0100 Subject: [PATCH] guix: import: Harden beautify-description. * guix/import/utils.scm (beautify-description): Handle non-string arguments. * guix/import/opam.scm: [use-modules] Make imports explicit for module (guix import utils). --- guix/import/opam.scm | 8 ++++++-- guix/import/utils.scm | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/guix/import/opam.scm b/guix/import/opam.scm index a6f6fe8c9f..f569c921b1 100644 --- a/guix/import/opam.scm +++ b/guix/import/opam.scm @@ -3,7 +3,7 @@ ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev> -;;; Copyright © 2021 Alice Brenon <alice.brenon@ens-lyon.fr> +;;; Copyright © 2021, 2022 Alice Brenon <alice.brenon@ens-lyon.fr> ;;; ;;; This file is part of GNU Guix. ;;; @@ -42,7 +42,11 @@ (define-module (guix import opam) #:use-module ((guix utils) #:select (cache-directory version>? call-with-temporary-output-file)) - #:use-module (guix import utils) + #:use-module ((guix import utils) #:select (beautify-description + guix-hash-url + recursive-import + spdx-string->license + url-fetch)) #:use-module ((guix licenses) #:prefix license:) #:export (opam->guix-package opam-recursive-import diff --git a/guix/import/utils.scm b/guix/import/utils.scm index 1c3cfa3e0b..cd716e3dc7 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -10,6 +10,7 @@ ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com> ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> +;;; Copyright © 2022 Alice Brenon <alice.brenon@ens-lyon.fr> ;;; ;;; This file is part of GNU Guix. ;;; @@ -241,6 +242,15 @@ (define* (beautify-description description #:optional (length 80)) a proper sentence and by using two spaces between sentences, and wrap lines at LENGTH characters." (let ((cleaned (cond + ((not (string? description)) + (let ((home-url "https://guix.gnu.org/") + (doc-path "fr/manual/devel/en/html_node/") + (page + "Synopses-and-Descriptions.html#Synopses-and-Descriptions")) + (string-append + "Please fill in the description of your package before " + "submitting ! See " + home-url doc-path page))) ((string-prefix? "A " description) (string-append "This package provides a" (substring description 1))) -- 2.34.0