diff options
Diffstat (limited to 'guix/scripts/pull.scm')
-rw-r--r-- | guix/scripts/pull.scm | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index 730b6a0bf2..2aaf1cc44a 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -181,6 +181,7 @@ Download and deploy the latest version of Guix.\n")) (new (profile-package-alist (generation-file-name profile current)))) (display-new/upgraded-packages old new + #:concise? #t #:heading (G_ "New in this revision:\n")))) (_ #t))) @@ -377,11 +378,33 @@ of packages upgraded in ALIST2." alist2))) (values new upgraded))) +(define* (ellipsis #:optional (port (current-output-port))) + "Return HORIZONTAL ELLIPSIS three dots if PORT's encoding cannot represent +it." + (match (port-encoding port) + ("UTF-8" "…") + (_ "..."))) + (define* (display-new/upgraded-packages alist1 alist2 - #:key (heading "")) + #:key (heading "") concise?) "Given the two package name/version alists ALIST1 and ALIST2, display the list of new and upgraded packages going from ALIST1 to ALIST2. When ALIST1 -and ALIST2 differ, display HEADING upfront." +and ALIST2 differ, display HEADING upfront. When CONCISE? is true, do not +display long package lists that would fill the user's screen." + (define (pretty str column) + (indented-string (fill-paragraph str (- (%text-width) 4) + column) + 4)) + + (define list->enumeration + (if concise? + (lambda* (lst #:optional (max 12)) + (if (> (length lst) max) + (string-append (string-join (take lst max) ", ") + ", " (ellipsis)) + (string-join lst ", "))) + (cut string-join <> ", "))) + (let-values (((new upgraded) (new/upgraded-packages alist1 alist2))) (unless (and (null? new) (null? upgraded)) (display heading)) @@ -392,21 +415,16 @@ and ALIST2 differ, display HEADING upfront." (format #t (N_ " ~h new package: ~a~%" " ~h new packages: ~a~%" count) count - (indented-string - (fill-paragraph (string-join (sort (map first new) string<?) - ", ") - (- (%text-width) 4) 30) - 4)))) + (pretty (list->enumeration (sort (map first new) string<?)) + 30)))) (match (length upgraded) (0 #t) (count (format #t (N_ " ~h package upgraded: ~a~%" " ~h packages upgraded: ~a~%" count) count - (indented-string - (fill-paragraph (string-join (sort upgraded string<?) ", ") - (- (%text-width) 4) 35) - 4)))))) + (pretty (list->enumeration (sort upgraded string<?)) + 35)))))) (define (display-profile-content-diff profile gen1 gen2) "Display the changes in PROFILE GEN2 compared to generation GEN1." |