diff options
author | Ludovic Courtès <ludo@gnu.org> | 2022-02-14 16:27:52 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2022-02-27 18:06:14 +0100 |
commit | bc8bea1739294f2c939f3dbb663d834a4d1d5856 (patch) | |
tree | 8c72c5c1687741c2a93ac95e703fbbc51abaf60c | |
parent | 85a5110de79f4fe9fd822ede3915654ee699d6c5 (diff) | |
download | guix-bc8bea1739294f2c939f3dbb663d834a4d1d5856.tar.gz |
pull: '--news' no longer shows package lists.
* guix/scripts/pull.scm (display-channel-news): Return #t when news were displayed. (display-news): Add #:profile-news? parameter and honor it. Print something there were no news. (process-query): For 'display-news', call 'display-channel-news' directly. * doc/guix.texi (Invoking guix pull): Adjust accordingly.
-rw-r--r-- | doc/guix.texi | 17 | ||||
-rw-r--r-- | guix/scripts/pull.scm | 126 |
2 files changed, 79 insertions, 64 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index a6437729ff..7596b0567b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -4486,13 +4486,13 @@ 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}). +When @option{--details} is passed, additionally display new and upgraded +packages. -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}] @@ -4507,8 +4507,9 @@ revision as well as the corresponding news entries. If you pass upgraded in each generation compared to the previous one. @item --details -Instruct @option{--list-generations} to display more information about -the differences between subsequent generations---see above. +Instruct @option{--list-generations} or @option{--news} to display more +information about the differences between subsequent generations---see +above. @item --roll-back @cindex rolling back diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index 205697b3bd..838ff24e9c 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -143,14 +143,10 @@ Download and deploy the latest version of Guix.\n")) (option '("details") #f #f (lambda (opt name arg result) (alist-cons 'details? #t - (match (find (match-lambda - (('query 'list-generations _) - #t) - (_ #f)) - result) - (#t result) - (#f (cons `(query list-generations #f) - result)))))) + (if (assoc-ref result 'query) + result + (cons `(query list-generations #f) + result))))) (option '("roll-back") #f #f (lambda (opt name arg result) (cons '(generation roll-back) @@ -165,7 +161,8 @@ Download and deploy the latest version of Guix.\n")) result))) (option '(#\N "news") #f #f (lambda (opt name arg result) - (cons '(query display-news) result))) + (cons '(query display-news) + (alist-delete 'query result)))) (option '("url") #t #f (lambda (opt name arg result) (alist-cons 'repository-url arg @@ -352,45 +349,48 @@ to display." (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 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)) - - (and old (list new old))) - new-channels))))))) + "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. + (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))))))) (define* (display-channel-news-headlines profile) "Display the titles of news about the channels of PROFILE compared to its @@ -421,13 +421,26 @@ previous generation. Return true if there are news to display." (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 profile)) +(define* (display-news profile #:key (profile-news? #f)) + "Display channel news for PROFILE compared to its previous generation. When +PROFILE-NEWS? is true, display the list of added/upgraded packages since the +previous generation." + (define previous + (relative-generation profile -1)) + + (if previous + (begin + (when profile-news? + (display-profile-news profile + #:current-is-newer? #t)) + + (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 @@ -698,7 +711,8 @@ Return true when there is more package info to display." (lambda () (list-generations profile numbers)))))))))) (('display-news) - (display-news profile)))) + (display-news profile + #:profile-news? (assoc-ref opts 'details?))))) (define (process-generation-change opts profile) "Process a request to change the current generation (roll-back, switch, delete)." |