From e77fc1c06876bc65e0782af3bd1ebdbef4bc1ea3 Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Fri, 30 Apr 2021 22:55:41 +0200 Subject: [PATCH 08/11] etc: committer: Perform line-wrapping. * etc/committer.scm.in (change-commit-message): Perform line wrapping. --- etc/committer.scm.in | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/etc/committer.scm.in b/etc/committer.scm.in index f03f0daf2b..de8f954f4e 100755 --- a/etc/committer.scm.in +++ b/etc/committer.scm.in @@ -39,7 +39,9 @@ (ice-9 rdelim) (ice-9 textual-ports) (rnrs control) - (guix gexp)) + (guix gexp) + (texinfo) + (texinfo plain-text)) (define* (break-string str #:optional (max-line-length 70)) "Break the string STR into lines that are no longer than MAX-LINE-LENGTH. @@ -442,11 +444,23 @@ SUMMARY: first using a ‘void port’, then with the ‘real’ output port." (define* (change-commit-message file-name old new #:optional (port (current-output-port))) "Like change-commit-message/one-pass, but without requiring to be run twice -for a correct header." +for a correct header. Also perform line wrapping." (let ((summary (make-patch-summary))) (change-commit-message/one-pass file-name old new summary (%make-void-port "w")) - (change-commit-message/one-pass file-name old new summary port))) + (let* ((unwrapped-message + (call-with-output-string + (lambda (port) + (change-commit-message/one-pass + file-name old new summary port)))) + ;; Hack: use (texinfo) and (texinfo plain-text) for + ;; line wraping. Suggested by rekado on #guix. + (raw-message/stexi (texi-fragment->stexi unwrapped-message)) + (wrapped-message + (with-fluid* *line-width* 70 + (lambda () + (stexi->plain-text raw-message/stexi))))) + (put-string port wrapped-message)))) (define* (add-commit-message file-name variable-name #:optional (port (current-output-port))) "Print ChangeLog commit message for a change to FILE-NAME adding a definition." -- 2.31.1