Subject: Re: bug#53060: [PATCH 0/2] Allow the github updater to update git sources

From: Ludovic Courtès <[email-masked]>
Date: Sun, 16 Jan 2022 23:19:48 +0100

Hi,

Maxime Devos <[email-masked]> skribis:

> Follow-up to <https://issues.guix.gnu.org/50072>.
>
> To test, you can do
>
> $ make check
> $ ./pre-inst-env guix refresh -t github -u zig
>
> and verify that the version and sha256/base32 has been updated
> ([email-masked] doesn't work though; patches aren't applying cleanly).

Nice, applied!

One comment:

> +(define (call-with-releases thunk tags releases)
> +  (mock ((guix http-client) http-fetch
> +         (lambda* (uri #:key headers)
> +           (unless (string-prefix? "mock://" uri)
> +             (error "the URI ~a should not be used" uri))
> +           (define components
> +             (string-split (substring uri 8) #\/))
> +           (pk 'stuff components headers)
> +           (define (scm->json-port scm)
> +             (open-input-string (scm->json-string scm)))
> +           (match components
> +             (("repos" "foo" "foomatics" "releases")
> +              (scm->json-port releases))
> +             (("repos" "foo" "foomatics" "tags")
> +              (scm->json-port tags))
> +             (rest (error "TODO ~a" rest)))))
> +        (parameterize ((%github-api "mock://"))
> +          (thunk))))

I think the whole point of having the ‘%github-api’ parameter is that it
allows us to mock the HTTP server instead of having to override bindings
such as ‘http-fetch’.

I’d have a slight preference for doing that, similar to what is done in
tests/cpan.scm for instance.  WDYT?

Thanks,
Ludo’.