all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Simon Tournier <zimon.toutoune@gmail.com>
To: "Simon Tournier" <zimon.toutoune@gmail.com>,
	"Ludovic Courtès" <ludo@gnu.org>
Cc: "Josselin Poiret" <dev@jpoiret.xyz>,
	"Maxim Cournoyer" <maxim.cournoyer@gmail.com>,
	"Mathieu Othacehe" <othacehe@gnu.org>,
	"Tobias Geerinckx-Rice" <me@tobias.gr>,
	"Florian Pelz" <pelzflorian@pelzflorian.de>,
	71697@debbugs.gnu.org, "Christopher Baines" <guix@cbaines.net>,
	"Matthew Trzcinski" <matt@excalamus.com>,
	"Christopher Baines" <guix@cbaines.net>,
	"Florian Pelz" <pelzflorian@pelzflorian.de>,
	"Josselin Poiret" <dev@jpoiret.xyz>,
	"Ludovic Courtès" <ludo@gnu.org>,
	"Mathieu Othacehe" <othacehe@gnu.org>,
	"Matthew Trzcinski" <matt@excalamus.com>,
	"Maxim Cournoyer" <maxim.cournoyer@gmail.com>,
	"Simon Tournier" <zimon.toutoune@gmail.com>,
	"Tobias Geerinckx-Rice" <me@tobias.gr>
Subject: [bug#71697] [PATCH v5 1/3] scripts: lint: Add 'dry-run' option.
Date: Fri, 19 Jul 2024 20:38:08 +0200	[thread overview]
Message-ID: <29595ae1ec166885b3916f9239986da5a7fdad58.1721411923.git.zimon.toutoune@gmail.com> (raw)
In-Reply-To: <cover.1721411923.git.zimon.toutoune@gmail.com>

* guix/scripts/lint.scm (guix-lint)[show-package-checkers]: New procedure.
(show-help, %options): Add 'dry-run' option.
* doc/guix.texi: Document it.

Change-Id: I8c96e376d52c0961ccf2ab39f1fc856c762b089d
---
 doc/guix.texi         |  3 +++
 guix/scripts/lint.scm | 54 +++++++++++++++++++++++++++++++++++++++----
 2 files changed, 53 insertions(+), 4 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 5b77c84b4a..6043962038 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -15463,6 +15463,9 @@ Invoking guix lint
 List and describe all the available checkers that will be run on packages
 and exit.
 
+@item --dry-run
+Do not run the checkers.
+
 @item --checkers
 @itemx -c
 Only enable the checkers specified in a comma-separated list using the
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index ee3de51fb1..10abb05cf0 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -100,6 +100,8 @@ (define (show-help)
   (display (G_ "Usage: guix lint [OPTION]... [PACKAGE]...
 Run a set of checkers on the specified package; if none is specified,
 run the checkers on all packages.\n"))
+  (display (G_ "
+      --dry-run          do not run checkers "))
   (display (G_ "
   -c, --checkers=CHECKER1,CHECKER2...
                          only run the specified checkers"))
@@ -154,6 +156,9 @@ (define %options
         (option '(#\n "no-network") #f #f
                 (lambda (opt name arg result)
                   (alist-cons 'no-network? #t result)))
+        (option '("dry-run") #f #f
+                (lambda (opt name arg result)
+                  (alist-cons 'dry-run? #t result)))
         (find (lambda (option)
                 (member "load-path" (option-names option)))
               %standard-build-options)
@@ -218,14 +223,55 @@ (define-command (guix-lint . args)
                 (proc store))
               (proc #f)))
 
+        (define (show-package-checkers package checkers)
+          (let* ((name (package-name package))
+                 (version (package-version package))
+                 (loc (package-location package))
+                 (number-checkers (length checkers))
+                 (number-all-checkers (length %all-checkers)))
+            (cond
+             ((= number-all-checkers number-checkers)
+              (info loc (G_ "~a@~a: all the ~d checkers would run.~%")
+                    name version
+                    number-all-checkers))
+             ((= 0 number-checkers)
+              (info loc (G_ "~a@~a: none of ~d checkers would run~%")
+                    name version
+                    number-all-checkers))
+             (else
+              (let* ((excluded-checkers (lset-difference eq? %all-checkers checkers))
+                     (number-excluded-checkers (length excluded-checkers))
+                     (number-difference (- number-all-checkers number-excluded-checkers))
+                     (sorter (lambda (list-checkers)
+                               (sort (map (compose symbol->string lint-checker-name)
+                                          list-checkers)
+                                     string<?))))
+                (info loc (G_ "~a@~a: ~d/~d checkers would run")
+                      name version
+                      number-checkers
+                      number-all-checkers)
+                (if (< number-excluded-checkers number-difference)
+                    (format (current-error-port)
+                            (G_ " at the exclusion of:~{ ~a~}.~%")
+                            (sorter excluded-checkers))
+                    (format (current-error-port)
+                            ":~{ ~a~}.~%"
+                            (sorter checkers))))))))
+
         (call-maybe-with-store
          (lambda (store)
            (cond
             ((null? args)
-             (fold-packages (lambda (p r) (run-checkers p checkers
-                                                        #:store store)) '()))
+             (when (assoc-ref opts 'dry-run?)
+               (leave (G_ "too much information to display, did nothing and exit~%") ""))
+             (fold-packages (lambda (p r)
+                              (unless (assoc-ref opts 'dry-run?)
+                                  (run-checkers p checkers
+                                                #:store store))) '()))
             (else
              (for-each (lambda (package)
-                         (run-checkers package checkers
-                                       #:store store))
+                         (if (assoc-ref opts 'dry-run?)
+                             (show-package-checkers package checkers)
+                             (run-checkers package checkers
+                                           #:store store)))
                        args)))))))))
-- 
2.41.0





  reply	other threads:[~2024-07-19 18:40 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-21 17:22 [bug#71697] [PATCH] guix: lint: Honor 'no-archival?' package property Simon Tournier
2024-06-21 18:33 ` [bug#71697] [PATCH v2] guix: scripts: lint: Honor package property to exclude chercker Simon Tournier
2024-06-21 21:09   ` Liliana Marie Prikler
2024-06-22 14:29   ` MSavoritias
2024-06-22 15:40     ` Simon Tournier
2024-06-24  8:21       ` MSavoritias
2024-06-22 15:27 ` [bug#71697] [PATCH v3 1/2] scripts: lint: Add 'dry-run' option Simon Tournier
2024-06-22 15:27   ` [bug#71697] [PATCH v3 2/2] scripts: lint: Honor package property to exclude checkers Simon Tournier
2024-06-23 23:51     ` Maxim Cournoyer
2024-06-25 15:14     ` Ludovic Courtès
2024-06-25 17:14       ` Greg Hogan via Guix-patches
2024-06-26  8:24         ` Ricardo Wurmus
2024-06-26 19:28         ` Maxim Cournoyer
2024-06-27 16:38           ` Greg Hogan
2024-06-29  3:12             ` Maxim Cournoyer
2024-06-30 14:48               ` Dale Mellor
2024-07-01 20:44                 ` Maxim Cournoyer
     [not found]                   ` <72a5f3c9d0523b29ed99afd5a551b411f4c0e7f5.camel@rdmp.org>
2024-07-02  1:39                     ` Maxim Cournoyer
2024-07-12 13:36                 ` Simon Tournier
2024-07-05  7:40             ` Ludovic Courtès
2024-07-12 14:16             ` Simon Tournier
2024-07-25 15:19               ` Greg Hogan
2024-07-12 17:20           ` Simon Tournier
2024-06-23 23:54   ` [bug#71697] [PATCH v3 1/2] scripts: lint: Add 'dry-run' option Maxim Cournoyer
2024-07-12 17:22 ` [bug#71697] [PATCH v4 " Simon Tournier
2024-07-12 17:22   ` [bug#71697] [PATCH v4 2/2] scripts: lint: Honor package property to exclude checkers Simon Tournier
2024-07-18  9:19   ` [bug#71697] [PATCH v4 1/2] scripts: lint: Add 'dry-run' option Ludovic Courtès
2024-07-18 11:00     ` Simon Tournier
2024-07-19 18:27 ` [bug#71697] [PATCH v5 0/3] Add dry-run to guix lint Simon Tournier
2024-07-19 18:38   ` Simon Tournier [this message]
2024-07-26  2:06     ` [bug#71697] [PATCH v5 1/3] scripts: lint: Add 'dry-run' option Maxim Cournoyer
2024-07-19 18:38   ` [bug#71697] [PATCH v5 2/3] scripts: lint: Honor package property to exclude checkers Simon Tournier
2024-07-19 18:38   ` [bug#71697] [PATCH v5 3/3] scripts: lint: Add hint for checker typo Simon Tournier
2024-07-26  2:26     ` Maxim Cournoyer

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

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

  git send-email \
    --in-reply-to=29595ae1ec166885b3916f9239986da5a7fdad58.1721411923.git.zimon.toutoune@gmail.com \
    --to=zimon.toutoune@gmail.com \
    --cc=71697@debbugs.gnu.org \
    --cc=dev@jpoiret.xyz \
    --cc=guix@cbaines.net \
    --cc=ludo@gnu.org \
    --cc=matt@excalamus.com \
    --cc=maxim.cournoyer@gmail.com \
    --cc=me@tobias.gr \
    --cc=othacehe@gnu.org \
    --cc=pelzflorian@pelzflorian.de \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.