Subject: Re: [bug#27550] [PATCH 0/2] cuirass: Prepare (guix git) integration.

From: [email-masked] (Ludovic Courtès)
Date: Tue, 04 Jul 2017 23:32:37 +0200

Hi Mathieu,

Mathieu Othacehe <[email-masked]> skribis:

> From 37d7b68c1e89a2873673613f4781efb6acda529b Mon Sep 17 00:00:00 2001
> From: Mathieu Othacehe <[email-masked]>
> Date: Sat, 1 Jul 2017 12:29:59 +0200
> Subject: [PATCH] base: Use (guix git) module.
>
> * src/cuirass/base.scm (copy-repository-cache) : New procedure.
> (fetch-repository): Use latest-repository-commit to fetch git
> repository instead of raw git system commands.
> (process-specs): Use fetch-repository to get a store directory
> containing the repository described in SPEC, add copy it to cache with
> "copy-repository-cache".

Looks nice!

> +(define (fetch-repository store spec)
> +  "Get the latest version of repository specified in SPEC.  Return two
> +values: the content of the git repository at URL copied into a store
> +directory and the sha1 of the top level commit in this directory."
> +
> +  (define (add-origin branch)
> +    "Prefix branch name with origin if no remote is specified."
> +    (if (string-index branch #\/)
> +        branch
> +        (string-append "origin/" branch)))
> +
> +  (let ((name   (assq-ref spec #:name))
> +        (url    (assq-ref spec #:url))
> +        (branch (and=> (assq-ref spec #:branch)
> +                       (lambda (b)
> +                         `(branch . ,(add-origin b)))))
> +        (commit (and=> (assq-ref spec #:commit)
> +                       (lambda (c)
> +                         `(commit . ,c))))
> +        (tag    (and=> (assq-ref spec #:tag)
> +                       (lambda (t)
> +                         `(tag . ,t)))))
> +    (latest-repository-commit store url
> +                              #:cache-directory (%package-cachedir)
> +                              #:ref (pk (or branch commit tag)))))

Leftover ‘pk’.  :-)

> +    (with-store store
> +      (let ((stamp (db-get-stamp db spec)))
> +        (receive (store-dir commit)
> +            (fetch-repository store spec)

Maybe s/store-dir/checkout/ for clarity.

Please add a check for (guix git) in configure.ac.

Now there are ‘git-error’ exception that can be thrown from there.
Should the ‘cuirass’ program catch them, report them on stderr, and keep
going?  Maybe we can ignore that for now (throwing is better than
silently ignoring Git problems anyway.)

Thanks,
Ludo’.