From patchwork Sat Sep 21 21:12:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 15431 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9227417400; Sat, 21 Sep 2019 22:14:04 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 45E8B173FB for ; Sat, 21 Sep 2019 22:14:04 +0100 (BST) Received: from localhost ([::1]:43764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBmhf-0003dA-SQ for patchwork@mira.cbaines.net; Sat, 21 Sep 2019 17:14:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41401) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBmgo-00032g-9u for guix-patches@gnu.org; Sat, 21 Sep 2019 17:13:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBmgm-0005yi-Tu for guix-patches@gnu.org; Sat, 21 Sep 2019 17:13:10 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:52663) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBmgm-0005xl-NZ for guix-patches@gnu.org; Sat, 21 Sep 2019 17:13:08 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iBmgm-0000On-G0 for guix-patches@gnu.org; Sat, 21 Sep 2019 17:13:08 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#37413] [PATCH v2 07/11] pull: Display channel news. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 21 Sep 2019 21:13:08 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37413 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 37413@debbugs.gnu.org Received: via spool by 37413-submit@debbugs.gnu.org id=B37413.15691003801439 (code B ref 37413); Sat, 21 Sep 2019 21:13:08 +0000 Received: (at 37413) by debbugs.gnu.org; 21 Sep 2019 21:13:00 +0000 Received: from localhost ([127.0.0.1]:33235 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iBmge-0000N6-F6 for submit@debbugs.gnu.org; Sat, 21 Sep 2019 17:13:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32826) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iBmgZ-0000LF-Ou for 37413@debbugs.gnu.org; Sat, 21 Sep 2019 17:12:57 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:49544) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iBmgU-0005fW-MU; Sat, 21 Sep 2019 17:12:50 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=53014 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1iBmgU-00065A-7b; Sat, 21 Sep 2019 17:12:50 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Sat, 21 Sep 2019 23:12:24 +0200 Message-Id: <20190921211228.13096-8-ludo@gnu.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190921211228.13096-1-ludo@gnu.org> References: <87sgow0w7w.fsf@gnu.org> <20190921211228.13096-1-ludo@gnu.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/scripts/pull.scm (display-news-entry) (display-channel-specific-news): New procedures. (display-channel-news): Call it. (display-new/upgraded-packages): Adjust hint message. * doc/guix.texi (Invoking guix pull): Mention it. --- doc/guix.texi | 11 +++++--- guix/scripts/pull.scm | 61 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 65 insertions(+), 7 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 5addb1f5ee..50adce4dd3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3720,13 +3720,16 @@ Read the list of channels from @var{file} instead of evaluates to a list of channel objects. @xref{Channels}, for more information. +@cindex channel news @item --news @itemx -N -Display the list of packages added or upgraded since the previous generation. +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}). -This is the same information 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). +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). @item --list-generations[=@var{pattern}] @itemx -l [@var{pattern}] diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index 4091f926ac..85291c3745 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -19,6 +19,7 @@ (define-module (guix scripts pull) #:use-module (guix ui) + #:use-module (guix colors) #:use-module (guix utils) #:use-module ((guix status) #:select (with-status-verbosity)) #:use-module (guix scripts) @@ -229,6 +230,48 @@ purposes." ;; Assume that the URL matters less than the name. (eq? (channel-name channel1) (channel-name channel2))) +(define (display-news-entry entry language port) + "Display ENTRY, a , in LANGUAGE, a language code, to +PORT." + (let ((title (channel-news-entry-title entry)) + (body (channel-news-entry-body entry))) + (format port " ~a~%" + (highlight + (string-trim-right + (texi->plain-text (or (assoc-ref title language) + (assoc-ref title (%default-message-language)) + ""))))) + (format port (G_ " commit ~a~%") + (channel-news-entry-commit entry)) + (newline port) + (format port " ~a~%" + (indented-string + (parameterize ((%text-width (- (%text-width) 4))) + (string-trim-right + (texi->plain-text (or (assoc-ref body language) + (assoc-ref body (%default-message-language)) + "")))) + 4)))) + +(define* (display-channel-specific-news new old + #:key (port (current-output-port))) + "Display channel news applicable the commits between OLD and NEW, where OLD +and NEW are records with a proper 'commit' field." + (let ((channel new) + (old (channel-commit old)) + (new (channel-commit new))) + (when (and old new) + (let ((language (current-message-language))) + (match (channel-news-for-commit channel new old) + (() ;no news is good news + #t) + ((entries ...) + (newline port) + (format port (G_ "News for channel '~a'~%") + (channel-name channel)) + (for-each (cut display-news-entry <> language port) entries) + (newline port))))))) + (define (display-channel-news profile) "Display new about the channels of PROFILE " (define previous @@ -259,7 +302,20 @@ purposes." (N_ " ~*One channel removed:~%" " ~a channels removed:~%" count) count) - (for-each display-channel removed))))))))) + (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))))))) (define (display-news profile) ;; Display profile news, with the understanding that this process represents @@ -534,8 +590,7 @@ display long package lists that would fill the user's screen." (when (and concise? (or (> new-count concise/max-item-count) (> upgraded-count concise/max-item-count))) - (display-hint (G_ "Run @command{guix pull --news} to view the complete -list of package changes."))))) + (display-hint (G_ "Run @command{guix pull --news} to read all the news."))))) (define (display-profile-content-diff profile gen1 gen2) "Display the changes in PROFILE GEN2 compared to generation GEN1."