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.
This commit is contained in:
Ludovic Courtès 2022-02-14 16:27:52 +01:00
parent 85a5110de7
commit bc8bea1739
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 76 additions and 61 deletions

View file

@ -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

View file

@ -143,14 +143,10 @@ (define %options
(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 @@ (define %options
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,8 +349,9 @@ (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
"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)
@ -381,9 +379,11 @@ (define* (display-channel-news profile
;; 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)))
(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 <>)
@ -421,13 +421,26 @@ (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)
(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))
(display-channel-news profile))
(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 @@ (define (list-generations profile numbers)
(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)."