diff mbox series

[bug#63647,v3,1/3] guix: import: go: Sort hint about available versions.

Message ID a520128590d4b67af4c2b22ae167590b99e449dd.1685030838.git.zimon.toutoune@gmail.com
State New
Headers show
Series [bug#63647,v3,1/3] guix: import: go: Sort hint about available versions. | expand

Commit Message

Simon Tournier May 25, 2023, 4:07 p.m. UTC
* guix/import/go.scm (validate-version): Sort available versions.
 guix/import/go.scm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

base-commit: 99fc7e5dd3c9c92f9b6c2e51db9dc5b0481a56b2


Ludovic Courtès June 5, 2023, 12:43 p.m. UTC | #1

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

> * guix/import/go.scm (validate-version): Sort available versions.


> From: Stephen Paul Weber <singpolyma@singpolyma.net>
> * guix/import/go.scm (vcs->origin): New argument module-path-subdirectory.
> Use it to get Git tag as described by <https://go.dev/ref/mod>.
> Co-authored-by: Simon Tournier <zimon.toutoune@gmail.com>
> Signed-off-by: Simon Tournier <zimon.toutoune@gmail.com>


> -(define (vcs->origin vcs-type vcs-repo-url version)
> +(define (vcs->origin vcs-type vcs-repo-url module-path-subdirectory version)
>    "Generate the `origin' block of a package depending on what type of source
>  control system is being used."

Maybe just ‘subdirectory’?  (In general ‘path’ is used for search paths,
not for file names, but I see this module already used the term with
that meaning.)

Also please mention it in the docstring.

Should there be a test, or is it too tricky?

diff mbox series


diff --git a/guix/import/go.scm b/guix/import/go.scm
index 0357e6a1eb..1943869162 100644
--- a/guix/import/go.scm
+++ b/guix/import/go.scm
@@ -34,6 +34,7 @@  (define-module (guix import go)
   #:use-module (guix packages)
   #:use-module (guix http-client)
   #:use-module (guix memoization)
+  #:use-module (guix utils)
   #:autoload   (htmlprag) (html->sxml)            ;from Guile-Lib
   #:autoload   (guix base32) (bytevector->nix-base32-string)
   #:autoload   (guix build utils) (mkdir-p)
@@ -588,8 +589,9 @@  (define (validate-version version available-versions module-path)
         (condition (&fix-hint
                     (hint (format #f (G_ "Pick one of the following \
 available versions:~{ ~a~}.")
-                                  (map strip-v-prefix
-                                       available-versions)))))))))
+                                  (sort (map strip-v-prefix
+                                             available-versions)
+                                        version>?)))))))))
 (define* (go-module->guix-package module-path #:key
                                   (goproxy "https://proxy.golang.org")