guix-commits
[Top][All Lists]
Advanced

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

06/08: refresh: '--list-updaters' shows updater coverage.


From: Ludovic Courtès
Subject: 06/08: refresh: '--list-updaters' shows updater coverage.
Date: Wed, 30 Nov 2016 16:35:27 +0000 (UTC)

civodul pushed a commit to branch master
in repository guix.

commit 3676f892551d562e1a1360d79b208e687ece08c2
Author: Ludovic Courtès <address@hidden>
Date:   Wed Nov 30 16:45:19 2016 +0100

    refresh: '--list-updaters' shows updater coverage.
    
    * guix/scripts/refresh.scm (list-updaters-and-exit): Compute the
    coverage ratio of each updater and print it.  Print the coverage ratio
    for all the updaters.
    * doc/guix.texi (Invoking guix refresh): Document it.
---
 doc/guix.texi            |    3 +++
 guix/scripts/refresh.scm |   27 ++++++++++++++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 37bdb69..3b4ba48 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -5394,6 +5394,9 @@ be used when passing @command{guix refresh} one or more 
package names:
 @itemx -L
 List available updaters and exit (see @option{--type} above.)
 
+For each updater, display the fraction of packages it covers; at the
+end, display the fraction of packages covered by all these updaters.
+
 @item --list-dependent
 @itemx -l
 List top-level dependent packages that would need to be rebuilt as a
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index 12a344e..e1ff544 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -220,11 +220,28 @@ unavailable optional dependencies such as Guile-JSON."
 (define (list-updaters-and-exit)
   "Display available updaters and exit."
   (format #t (_ "Available updaters:~%"))
-  (for-each (lambda (updater)
-              (format #t "- ~a: ~a~%"
-                      (upstream-updater-name updater)
-                      (_ (upstream-updater-description updater))))
-            %updaters)
+  (newline)
+
+  (let* ((packages (fold-packages cons '()))
+         (total    (length packages)))
+    (define covered
+      (fold (lambda (updater covered)
+              (let ((matches (count (upstream-updater-predicate updater)
+                                    packages)))
+                ;; TRANSLATORS: The parenthetical expression here is rendered
+                ;; like "(42% coverage)" and denotes the fraction of packages
+                ;; covered by the given updater.
+                (format #t (_ "  - ~a: ~a (~2,1f% coverage)~%")
+                        (upstream-updater-name updater)
+                        (_ (upstream-updater-description updater))
+                        (* 100. (/ matches total)))
+                (+ covered matches)))
+            0
+            %updaters))
+
+    (newline)
+    (format #t (_ "~2,1f% of the packages are covered by these updaters.~%")
+            (* 100. (/ covered total))))
   (exit 0))
 
 (define (warn-no-updater package)



reply via email to

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