diff mbox series

[bug#71697,v3,1/2] scripts: lint: Add 'dry-run' option.

Message ID 1f9e0a732fff5c6460e6da9500ea5b748882e38d.1719069966.git.zimon.toutoune@gmail.com
State New
Headers show
Series [bug#71697,v3,1/2] scripts: lint: Add 'dry-run' option. | expand

Commit Message

Simon Tournier June 22, 2024, 3:27 p.m. UTC
* guix/scripts/lint.scm (show-help, %options): Add 'dry-run' option.
(guix-lint): Use it.
* doc/guix.texi: Document it.

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


base-commit: bc8a41f4a8d9f1f0525d7bc97c67ed3c8aea3111

Comments

Maxim Cournoyer June 23, 2024, 11:54 p.m. UTC | #1
Hi,

Simon Tournier <zimon.toutoune@gmail.com> writes:

> * guix/scripts/lint.scm (show-help, %options): Add 'dry-run' option.
> (guix-lint): Use it.
> * doc/guix.texi: Document it.
>
> Change-Id: I8c96e376d52c0961ccf2ab39f1fc856c762b089d
> ---
>  doc/guix.texi         |  3 +++
>  guix/scripts/lint.scm | 16 ++++++++++++----
>  2 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/doc/guix.texi b/doc/guix.texi
> index 769ca1399f..037b1a2f24 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -15459,6 +15459,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.

Does it print which checkers would run?  Otherwise I don't see the
usefulness.
diff mbox series

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index 769ca1399f..037b1a2f24 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -15459,6 +15459,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..b98266c831 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)
@@ -222,10 +227,13 @@  (define-command (guix-lint . args)
          (lambda (store)
            (cond
             ((null? args)
-             (fold-packages (lambda (p r) (run-checkers p checkers
-                                                        #:store store)) '()))
+             (fold-packages (lambda (p r)
+                              (when (not (assoc-ref opts 'dry-run?))
+                                (run-checkers p checkers
+                                              #:store store))) '()))
             (else
              (for-each (lambda (package)
-                         (run-checkers package checkers
-                                       #:store store))
+                         (when (not (assoc-ref opts 'dry-run?))
+                             (run-checkers package checkers
+                                           #:store store)))
                        args)))))))))