import/utils: beautify-description: Validate argument.

* guix/import/utils.scm (beautify-description): Fix broken check for
non-strings.  Add a check for empty strings.
* tests/import-utils.scm: Add two tests.

Change-Id: Idf86df02aeb850fcc8808b7c9251082c1f816656
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Morgan Smith 2025-04-07 16:53:52 -04:00 committed by Ludovic Courtès
parent 47a5cd9f9c
commit 0772d36076
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 14 additions and 4 deletions

View file

@ -331,9 +331,9 @@ are replaced with dashes."
"Improve the package DESCRIPTION by turning a beginning sentence fragment into
a proper sentence and by using two spaces between sentences, and wrap lines at
LENGTH characters."
(unless (string? description)
(G_ "This package lacks a description. Run \
\"info '(guix) Synopses and Descriptions'\" for more information."))
(if (or (not (string? description)) (string=? (string-trim-both description) ""))
(G_ "This package lacks a description. Run \
\"info '(guix) Synopses and Descriptions'\" for more information.")
(let* ((fix-word
(lambda (word)
@ -410,7 +410,7 @@ LENGTH characters."
". "
". ")))
'post)
length)))
length))))
(define (beautify-synopsis synopsis)
"Improve the package SYNOPSIS."

View file

@ -31,6 +31,16 @@
(test-begin "import-utils")
(test-equal "beautify-description: empty string"
"This package lacks a description. Run \
\"info '(guix) Synopses and Descriptions'\" for more information."
(beautify-description ""))
(test-equal "beautify-description: not a string"
"This package lacks a description. Run \
\"info '(guix) Synopses and Descriptions'\" for more information."
(beautify-description '()))
(test-equal "beautify-description: use double spacing"
"\
Trust me Mr. Hendrix, M. Night Shyamalan et al. \