guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#54000] [PATCH 1/2] pull: '--news' no longer shows package lists.


From: Ludovic Courtès
Subject: [bug#54000] [PATCH 1/2] pull: '--news' no longer shows package lists.
Date: Mon, 14 Feb 2022 17:41:26 +0100

* guix/scripts/pull.scm (display-channel-news): Return #t when news were
displayed.
(display-news): Remove call to 'display-profile-news'.  Print something
when there were no news.
(process-query): For 'display-news', call 'display-channel-news'
directly.
* doc/guix.texi (Invoking guix pull): Adjust accordingly.
---
 doc/guix.texi         | 10 ++---
 guix/scripts/pull.scm | 93 ++++++++++++++++++++++++-------------------
 2 files changed, 55 insertions(+), 48 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index a05f073c3d..534414ab8a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4486,13 +4486,11 @@ information.
 @cindex channel news
 @item --news
 @itemx -N
-Display the list of packages added or upgraded since the previous
-generation, as well as, occasionally, news written by channel authors
-for their users (@pxref{Channels, Writing Channel News}).
+Display news written by channel authors for their users for changes made
+since the previous generation (@pxref{Channels, Writing Channel News}).
 
-The package information is the same as displayed upon @command{guix
-pull} completion, but without ellipses; it is also similar to the output
-of @command{guix pull -l} for the last generation (see below).
+You can view that information for previous generations with
+@command{guix pull -l}.
 
 @item --list-generations[=@var{pattern}]
 @itemx -l [@var{pattern}]
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 205697b3bd..af1b27d7dd 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -352,45 +352,48 @@ (define* (display-channel-news profile
                                (previous
                                 (and=> (relative-generation profile -1)
                                        (cut generation-file-name profile <>))))
-  "Display news about the channels of PROFILE compared to PREVIOUS."
-  (when previous
-    (let ((old-channels (profile-channels previous))
-          (new-channels (profile-channels profile)))
-      (and (pair? old-channels) (pair? new-channels)
-           (begin
-             (match (lset-difference channel=? new-channels old-channels)
-               (()
-                #t)
-               (new
-                (let ((count (length new)))
-                  (format (current-error-port)
-                          (N_ "  ~a new channel:~%"
-                              "  ~a new channels:~%" count)
-                          count)
-                  (for-each display-channel new))))
-             (match (lset-difference channel=? old-channels new-channels)
-               (()
-                #t)
-               (removed
-                (let ((count (length removed)))
-                  (format (current-error-port)
-                          (N_ "  ~a channel removed:~%"
-                              "  ~a channels removed:~%" count)
-                          count)
-                  (for-each display-channel removed))))
+  "Display news about the channels of PROFILE compared to PREVIOUS.  Return
+true if news were displayed, false otherwise."
+  (and previous
+       (let ((old-channels (profile-channels previous))
+             (new-channels (profile-channels profile)))
+         (and (pair? old-channels) (pair? new-channels)
+              (begin
+                (match (lset-difference channel=? new-channels old-channels)
+                  (()
+                   #t)
+                  (new
+                   (let ((count (length new)))
+                     (format (current-error-port)
+                             (N_ "  ~a new channel:~%"
+                                 "  ~a new channels:~%" count)
+                             count)
+                     (for-each display-channel new))))
+                (match (lset-difference channel=? old-channels new-channels)
+                  (()
+                   #t)
+                  (removed
+                   (let ((count (length removed)))
+                     (format (current-error-port)
+                             (N_ "  ~a channel removed:~%"
+                                 "  ~a channels removed:~%" count)
+                             count)
+                     (for-each display-channel removed))))
 
-             ;; Display channel-specific news for those channels that were
-             ;; here before and are still around afterwards.
-             (for-each (match-lambda
-                         ((new old)
-                          (display-channel-specific-news new old)))
-                       (filter-map (lambda (new)
-                                     (define old
-                                       (find (cut channel=? new <>)
-                                             old-channels))
+                ;; Display channel-specific news for those channels that were
+                ;; here before and are still around afterwards.
+                (fold (match-lambda*
+                        (((new old) news?)
+                         (or (display-channel-specific-news new old)
+                             news?)))
+                      #f
+                      (filter-map (lambda (new)
+                                    (define old
+                                      (find (cut channel=? new <>)
+                                            old-channels))
 
-                                     (and old (list new old)))
-                                   new-channels)))))))
+                                    (and old (list new old)))
+                                  new-channels)))))))
 
 (define* (display-channel-news-headlines profile)
   "Display the titles of news about the channels of PROFILE compared to its
@@ -422,12 +425,18 @@ (define more?
              (any ->bool more?))))))
 
 (define (display-news profile)
-  ;; Display profile news, with the understanding that this process represents
-  ;; the newest generation.
-  (display-profile-news profile
-                        #:current-is-newer? #t)
+  "Display channel news for PROFILE compared to its previous generation."
+  (define previous
+    (relative-generation profile -1))
 
-  (display-channel-news profile))
+  (if previous
+      (unless (display-channel-news profile
+                                    (generation-file-name profile previous))
+        (info (G_ "no channel news since generation ~a~%") previous)
+        (display-hint (G_ "Run @command{guix pull -l} to view the
+news for earlier generations.")))
+      (leave (G_ "profile ~a does not have a previous generation~%")
+             profile)))
 
 (define* (build-and-install instances profile)
   "Build the tool from SOURCE, and install it in PROFILE.  When DRY-RUN? is
-- 
2.34.0






reply via email to

[Prev in Thread] Current Thread [Next in Thread]