unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 37413@debbugs.gnu.org
Subject: [bug#37413] [PATCH v2 01/11] pull: '--news' shows the list of channels added or removed.
Date: Sat, 21 Sep 2019 23:12:18 +0200	[thread overview]
Message-ID: <20190921211228.13096-2-ludo@gnu.org> (raw)
In-Reply-To: <20190921211228.13096-1-ludo@gnu.org>

* guix/scripts/pull.scm (display-channel, channel=?)
(display-channel-news, display-news): New procedures.
(process-query): Call 'display-news' instead of 'display-profile-news'.
---
 guix/scripts/pull.scm | 61 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 57 insertions(+), 4 deletions(-)

diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index c9835cef34..4091f926ac 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -213,6 +213,62 @@ newest generation of PROFILE."
                                         (G_ "New in this revision:\n")))))
     (_ #t)))
 
+(define (display-channel channel)
+  "Display information about CHANNEL."
+  (format (current-error-port)
+          ;; TRANSLATORS: This describes a "channel"; the first placeholder is
+          ;; the channel name (e.g., "guix") and the second placeholder is its
+          ;; URL.
+          (G_ "    ~a at ~a~%")
+          (channel-name channel)
+          (channel-url channel)))
+
+(define (channel=? channel1 channel2)
+  "Return true if CHANNEL1 and CHANNEL2 are the same for all practical
+purposes."
+  ;; Assume that the URL matters less than the name.
+  (eq? (channel-name channel1) (channel-name channel2)))
+
+(define (display-channel-news profile)
+  "Display new about the channels of PROFILE "
+  (define previous
+    (and=> (relative-generation profile -1)
+           (cut generation-file-name profile <>)))
+
+  (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_ "  ~*One 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_ "  ~*One channel removed:~%"
+                              "  ~a channels removed:~%" count)
+                          count)
+                  (for-each display-channel removed)))))))))
+
+(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* (build-and-install instances profile
                             #:key use-substitutes? verbose? dry-run?)
   "Build the tool from SOURCE, and install it in PROFILE.  When DRY-RUN? is
@@ -521,10 +577,7 @@ list of package changes.")))))
                ((numbers ...)
                 (list-generations profile numbers)))))))
     (('display-news)
-     ;; Display profile news, with the understanding that this process
-     ;; represents the newest generation.
-     (display-profile-news profile
-                           #:current-is-newer? #t))))
+     (display-news profile))))
 
 (define (process-generation-change opts profile)
   "Process a request to change the current generation (roll-back, switch, delete)."
-- 
2.23.0

  reply	other threads:[~2019-09-21 21:13 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-15 22:10 [bug#37413] [PATCH 0/9] Channel news distribution mechanism Ludovic Courtès
2019-09-15 22:20 ` [bug#37413] [PATCH 1/9] pull: '--news' shows the list of channels added or removed Ludovic Courtès
2019-09-15 22:20   ` [bug#37413] [PATCH 2/9] git: 'update-cached-checkout' avoids network access when unnecessary Ludovic Courtès
2019-09-15 22:21   ` [bug#37413] [PATCH 3/9] git: Add 'commit-difference' Ludovic Courtès
2019-09-15 22:21   ` [bug#37413] [PATCH 4/9] channels: Add support for a news file Ludovic Courtès
2019-09-15 22:21   ` [bug#37413] [PATCH 5/9] ui: Add 'current-message-language' Ludovic Courtès
2019-09-15 22:21   ` [bug#37413] [PATCH 6/9] pull: Display channel news Ludovic Courtès
2019-09-15 22:21   ` [bug#37413] [PATCH 7/9] pull: '-l' displays " Ludovic Courtès
2019-09-15 22:21   ` [bug#37413] [PATCH 8/9] Add '.guix-channel' file Ludovic Courtès
2019-09-15 22:21   ` [bug#37413] [PATCH 9/9] DRAFT etc: Add channel news file Ludovic Courtès
2019-09-16  9:31 ` [bug#37413] [PATCH 0/9] Channel news distribution mechanism Ricardo Wurmus
2019-09-16 12:59   ` Ludovic Courtès
2019-09-16 13:16     ` Ricardo Wurmus
2019-09-16 15:10       ` Ludovic Courtès
2019-09-16 17:16         ` Ricardo Wurmus
2019-09-16 21:25 ` Ludovic Courtès
2019-09-16 21:49   ` Julien Lepiller
2019-09-16 22:52     ` pelzflorian (Florian Pelz)
2019-09-17 12:44       ` Ludovic Courtès
2019-09-17 13:33         ` pelzflorian (Florian Pelz)
2019-09-17 13:39           ` Ludovic Courtès
2019-09-17 14:28             ` pelzflorian (Florian Pelz)
2019-09-17 15:27               ` Ludovic Courtès
2019-09-17 17:41                 ` pelzflorian (Florian Pelz)
2019-09-17 18:21                   ` Julien Lepiller
2019-09-17 19:44                     ` pelzflorian (Florian Pelz)
2019-09-17 22:02                       ` pelzflorian (Florian Pelz)
2019-09-18 10:02                       ` Ludovic Courtès
2019-09-18 11:49                         ` pelzflorian (Florian Pelz)
2019-09-18 12:33                           ` Ludovic Courtès
2019-09-18  9:12                     ` Ludovic Courtès
2019-09-21 21:12   ` [bug#37413] [PATCH v2 00/11] " Ludovic Courtès
2019-09-21 21:12     ` Ludovic Courtès [this message]
2019-09-21 21:12     ` [bug#37413] [PATCH v2 02/11] git: 'update-cached-checkout' avoids network access when unnecessary Ludovic Courtès
2019-09-21 21:12     ` [bug#37413] [PATCH v2 03/11] git: Add 'commit-difference' Ludovic Courtès
2019-09-21 21:12     ` [bug#37413] [PATCH v2 04/11] channels: Add support for a news file Ludovic Courtès
2019-09-21 21:12     ` [bug#37413] [PATCH v2 05/11] channels: Allow news entries to refer to a tag Ludovic Courtès
2019-09-21 21:12     ` [bug#37413] [PATCH v2 06/11] ui: Add 'current-message-language' Ludovic Courtès
2019-09-21 21:12     ` [bug#37413] [PATCH v2 07/11] pull: Display channel news Ludovic Courtès
2019-09-21 21:12     ` [bug#37413] [PATCH v2 08/11] pull: '-l' displays " Ludovic Courtès
2019-09-21 21:12     ` [bug#37413] [PATCH v2 09/11] pull: Display news titles directly upon 'pull' Ludovic Courtès
2019-09-21 21:12     ` [bug#37413] [PATCH v2 10/11] Add '.guix-channel' file Ludovic Courtès
2019-09-21 21:12     ` [bug#37413] [PATCH v2 11/11] DRAFT etc: Add channel news file Ludovic Courtès
2019-09-22 11:14       ` pelzflorian (Florian Pelz)
2019-09-23  9:13         ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190921211228.13096-2-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=37413@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).