Subject: [bug#73833] [PATCH v2 4/5] guix: refresh: Keep the version field of each update specification.

From: Ludovic Courtès <[email-masked]>
Date: Wed, 06 Nov 2024 16:47:51 +0100

Nicolas Graves <[email-masked]> skribis:

> * guix/scripts/refresh.scm (options->update-specs)[update-specs]: Keep
> the version field of each update specification.  This is done using a
> variable to cache package names and then filter out unwanted candidates.
> ---
>  guix/scripts/refresh.scm | 23 +++++++++++++++++------
>  1 file changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
> index ec7d38c22a..810c33c786 100644
> --- a/guix/scripts/refresh.scm
> +++ b/guix/scripts/refresh.scm
> @@ -310,12 +310,23 @@ (define update-specs
>         some)))
>  
>    (if (assoc-ref opts 'recursive?)
> -      (mlet* %store-monad ((edges (node-edges %bag-node-type (all-packages)))
> -                           (packages -> (node-transitive-edges
> -                                         (map update-spec-package update-specs)
> -                                         edges)))
> -        ;; FIXME: The 'version' field of each update spec is lost.
> -        (return (map update-spec packages)))
> +      (mlet* %store-monad
> +          ((edges (node-edges %bag-node-type (all-packages)))
> +           (strict-spec-pkgs -> (map update-spec-package update-specs))
> +           (strict-spec-pkg-names -> (map package-name strict-spec-pkgs))
> +           (packages -> (node-transitive-edges strict-spec-pkgs edges))
> +           (transitive-specs -> (map update-spec packages)))
> +        (return (append update-specs
> +                        (filter-map (match-lambda
> +                                      ((? update? spec)
> +                                       (if (member (package-name
> +                                                    (update-spec-package spec))
> +                                                   strict-spec-pkg-names)
> +                                           spec
> +                                           #f))
> +                                      (_
> +                                       #f))
> +                                    transitive-specs))))

Or just:

  (filter (lambda (spec)
            (member (package-name (update-spec-package spec))
                    package-names))
          transitive-specs)

(IIUC.)

Maybe add a comment explaining that this is to retain the ‘version’
field of UPDATE-SPECS?

Also, check out the guidelines for identifiers.

Thanks,
Ludo’.