From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id GD52Kcr3qWWkowAA62LTzQ:P1 (envelope-from ) for ; Fri, 19 Jan 2024 05:17:14 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id GD52Kcr3qWWkowAA62LTzQ (envelope-from ) for ; Fri, 19 Jan 2024 05:17:14 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=YBeDaq6j; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1705637834; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=ZzkFu4aDGH2Yp3208PqbfKpfSdSdXdu+FvJexNYdQKo=; b=XSSrINAnaShJ/xPinVC1OHFIzRSnK4SsX+mua/8Uwy7mI/UM/IGEO0/uLyZCwe3zKt68bb 8P0wuF6JHgSi44Bj1LdG9Z9NTSf7khFTu2H3s/iBIUb8XZpum4ENWfjVPJdta/27ba0ExW SO3Bj4k7nmEJ02xkBBHKDAcEoYEwjK9QJy0yZQgfLognciZ7i2jOJbOlL66ytwCeuv2GdF 3v4RbCgHAt9FDbO8hmc674GyOnqMmsRw2xmRoWoogVrdPlVptGCNjYySAFQU/Bkm3xllC0 FZPVJ/MffIVDLl9QroOFZ3e6bcj1m7+kcKREX0SMpl4Mp3LJPkRS8UTW05/WXw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=YBeDaq6j; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1705637834; a=rsa-sha256; cv=none; b=GDo3OLxywabKv6aRywR3aeuOiVRwZ0fc3HdN5GlmHCSxRAZitCdIsjIaaFxiuaM38WAghk UASxqVBa9tqF9si4kv7YEmY2Hno47pLOEaXdVqgiChK6ojFAL0BEtZMTJE/DjR0liyFEkf BgA5v07vQ7eXrOLslVjF6kOp2cTMrPf+7Abwmv4Z/Cr2bZVdR0gpX9DdkXcEqjEV/thTqo xgnTjrMujcT13yTNtcV4qIt4sGzw8xYoejGLvwCVrxsyNHg+W8bDP2r67OKC2Ad/HxKrJL 9BMkQVEEY+p+9IqsEDCSZNQSGnUGTE/MLkP9M8OaXZXkApe8bTy6fiqpxnHIsQ== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 249DF12B1F for ; Fri, 19 Jan 2024 05:17:14 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQgJU-0001lW-SM; Thu, 18 Jan 2024 23:17:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQgJR-0001lF-LY for guix-patches@gnu.org; Thu, 18 Jan 2024 23:17:01 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQgJQ-00053R-RG for guix-patches@gnu.org; Thu, 18 Jan 2024 23:17:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rQgJS-0000zo-C9 for guix-patches@gnu.org; Thu, 18 Jan 2024 23:17:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68405] [PATCH v2] guix: download: Add support for git repositories. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 19 Jan 2024 04:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68405 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Romain GARBAGE Cc: 68405@debbugs.gnu.org, Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 68405-submit@debbugs.gnu.org id=B68405.17056378173620 (code B ref 68405); Fri, 19 Jan 2024 04:17:02 +0000 Received: (at 68405) by debbugs.gnu.org; 19 Jan 2024 04:16:57 +0000 Received: from localhost ([127.0.0.1]:57154 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rQgJL-0000vr-Nh for submit@debbugs.gnu.org; Thu, 18 Jan 2024 23:16:57 -0500 Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]:55679) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rQgJI-0000pO-RX for 68405@debbugs.gnu.org; Thu, 18 Jan 2024 23:16:53 -0500 Received: by mail-qk1-x72f.google.com with SMTP id af79cd13be357-7833b6bb41bso31898885a.3 for <68405@debbugs.gnu.org>; Thu, 18 Jan 2024 20:16:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705637805; x=1706242605; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZzkFu4aDGH2Yp3208PqbfKpfSdSdXdu+FvJexNYdQKo=; b=YBeDaq6jm8UDKVK8Vb8QVCwFFWKwi5E5VV8D/gXBztdbrLCFkMdfVBk0i3K4CcFIOm g8pxFpRKzN3myAtM5ZGvi0lO9eja0XlM5go8H/VfJv8PcrufvZIiwVJsUBbmi8H2/wBq 8st2rxg+DTVSuiG8yZmGaN/h/05yNTx3EUnSfiH2Ur/7IF8uEEf3u4g/LmEaZ09aHa7g YqmHzPYgBplhDPaP5/TUY0rN2f/plQEv6HnlC/ziO4YNRZAtnlInySvRRhIzH2jBH3e2 Ev6/3X4ZHqpHr3BJCdZFGPajVtCx3R5nO0Tq7ZiRb/jZD3NbmltgcJ1toW0a6liartiG HQHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705637805; x=1706242605; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZzkFu4aDGH2Yp3208PqbfKpfSdSdXdu+FvJexNYdQKo=; b=ef8xcMYe9c8oBZ0lxCMaIWf9NAe97A0tnvRbj+hX7LCgCd/VC6PXjI2+SyuanrifRV Iq/CRDbquKNpZ2G8GSSvnPEn4npOFxBXRSpHICWDbyG/rpZxuLc6hkStyYZJSz4xeP4U YQWd3CrcDsDw3YYta2iV4twkJ0v4V8HHj8P8M0X4PjF1C9RC0lDWv5Pj9M84ixyP8YGf MIm1G0zSXCHaaINqtJknQYZbVuU6c1CDGveDzlLso5ZdOXNPSCUYa4k6yuNQZGvc8pr1 NeCmM/JrbYDss4a3cFgz5KbZxRho4PmCYsM7uAfRHvvGv0kWqzZKv7t1NsYP/w3hP9B8 E7aQ== X-Gm-Message-State: AOJu0YyEj6O/CwBy2bN+PYqF5Yx1wssZ7I6t7NwU/0tFjIGnma6Wfdmk 6uhlSyzd+5KBUxoYv6A1C5+fYvkNYTlXcBj363C/d1kyyAIeMI+6 X-Google-Smtp-Source: AGHT+IEP9aFnEYvqy9M+VPqoJigRowByPgu+CrKSlpdGapMLjbdS0EwqB/juxkYNUZopFUOPAafXfQ== X-Received: by 2002:a05:620a:1a17:b0:783:7fd1:dc90 with SMTP id bk23-20020a05620a1a1700b007837fd1dc90mr742314qkb.59.1705637804981; Thu, 18 Jan 2024 20:16:44 -0800 (PST) Received: from hurd (dsl-10-132-160.b2b2c.ca. [72.10.132.160]) by smtp.gmail.com with ESMTPSA id ha11-20020a05622a2b0b00b003f6ac526568sm7352889qtb.39.2024.01.18.20.16.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 20:16:44 -0800 (PST) From: Maxim Cournoyer In-Reply-To: <20240112151411.22470-2-romain.garbage@inria.fr> (Romain GARBAGE's message of "Fri, 12 Jan 2024 16:12:19 +0100") References: <20240112151411.22470-2-romain.garbage@inria.fr> Date: Thu, 18 Jan 2024 23:16:42 -0500 Message-ID: <87jzo6j6tx.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: 2.32 X-Migadu-Scanner: mx13.migadu.com X-Spam-Score: 2.32 X-Migadu-Queue-Id: 249DF12B1F X-TUID: A5pppl64mkR1 Hello, Romain GARBAGE writes: > Added `--recursive' option. I still see a TODO about supporting recursive repos in the code. Is that still the case? > Removed `pk' call. > > * guix/scripts/download.scm (git-download-to-store*): Add new variable. > (copy-recursively-without-dot-git): New variable. > (git-download-to-file): Add new variable. > (show-help): Add 'git', 'commit', 'branch' and 'recursive'options > help message. > (%default-options): Add default value for 'git-reference' and > 'recursive' options. > (%options): Add 'git', 'commit', 'branch' and 'recursive' command > line options. > (guix-download) [hash]: Compute hash with 'file-hash*' instead of > 'port-hash' from (gcrypt hash) module. This allows us to compute > hashes for directories. > * doc/guix.texi (Invoking guix-download): Add @item entries for > `git', `commit', `branch' and `recursive' options. Add a paragraph in > the introduction. > * tests/guix-download.sh: New tests. This sounds good and is something that I'm many many of us have wanted for some time. Thank you for working on it! Nitpick about the commit message: the convention seems to be to not use a hanging indent when writing GNU ChangeLog messages. > --- > doc/guix.texi | 23 ++++++ > guix/scripts/download.scm | 146 ++++++++++++++++++++++++++++++++++---- > tests/guix-download.sh | 42 +++++++++++ > 3 files changed, 199 insertions(+), 12 deletions(-) > > diff --git a/doc/guix.texi b/doc/guix.texi > index 3002cdfa13..d3b40e878b 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -13983,6 +13983,9 @@ the certificates of X.509 authorities from the directory pointed to by > the @env{SSL_CERT_DIR} environment variable (@pxref{X.509 > Certificates}), unless @option{--no-check-certificate} is used. > > +Alternatively, @command{guix download} can also retrieve a Git > +repository, possibly a specific commit, tag, or branch. > + > The following options are available: > > @table @code > @@ -14007,6 +14010,26 @@ URL, which makes you vulnerable to ``man-in-the-middle'' attacks. > @itemx -o @var{file} > Save the downloaded file to @var{file} instead of adding it to the > store. > + > +@item --git > +@itemx -g > +Checkout the Git repository at the latest commit on the default branch. > + > +@item --commit=@var{commit-or-tag} > +Checkout the Git repository at @var{commit-or-tag}. > + > +@var{commit-or-tag} can be either a tag or a commit defined in the Git > +repository. > + > +@item --branch=@var{branch} > +Checkout the Git repository at @var{branch}. > + > +The repository will be checked out at the latest commit of @var{branch}, > +which must be a valid branch of the Git repository. > + > +@item --recursive > +@itemx -r > +Recursively clone the Git repository. > @end table > > @node Invoking guix hash > diff --git a/guix/scripts/download.scm b/guix/scripts/download.scm > index 19052d5652..50c9a43791 100644 > --- a/guix/scripts/download.scm > +++ b/guix/scripts/download.scm > @@ -22,17 +22,23 @@ (define-module (guix scripts download) > #:use-module (guix scripts) > #:use-module (guix store) > #:use-module (gcrypt hash) > + #:use-module (guix hash) > #:use-module (guix base16) > #:use-module (guix base32) > #:autoload (guix base64) (base64-encode) > #:use-module ((guix download) #:hide (url-fetch)) > + #:use-module ((guix git) > + #:select (latest-repository-commit > + update-cached-checkout)) > #:use-module ((guix build download) > #:select (url-fetch)) > + #:use-module (guix build utils) > #:use-module ((guix progress) > #:select (current-terminal-columns)) > #:use-module ((guix build syscalls) > #:select (terminal-columns)) > #:use-module (web uri) > + #:use-module (ice-9 ftw) > #:use-module (ice-9 match) > #:use-module (srfi srfi-1) > #:use-module (srfi srfi-26) > @@ -54,6 +60,57 @@ (define (download-to-file url file) > (url-fetch url file #:mirrors %mirrors))) > file)) > > +;; This is a simplified version of 'copy-recursively'. > +;; It allows us to filter out the ".git" subfolder. > +;; TODO: Remove when 'copy-recursively' supports '#:select?'. Is a #:select? planned for copy-recursively? (in the works?) > +(define (copy-recursively-without-dot-git source destination) > + (define strip-source > + (let ((len (string-length source))) > + (lambda (file) > + (substring file len)))) > + > + (file-system-fold (lambda (file stat result) ; enter? > + (not (string-suffix? "/.git" file))) > + (lambda (file stat result) ; leaf > + (let ((dest (string-append destination > + (strip-source file)))) > + (case (stat:type stat) > + ((symlink) > + (let ((target (readlink file))) > + (symlink target dest))) > + (else > + (copy-file file dest))))) > + (lambda (dir stat result) ; down > + (let ((target (string-append destination > + (strip-source dir)))) > + (mkdir-p target))) > + (const #t) ; up > + (const #t) ; skip > + (lambda (file stat errno result) > + (format (current-error-port) "i/o error: ~a: ~a~%" > + file (strerror errno)) > + #f) > + #t > + source)) > + > +(define (git-download-to-file url file reference recursive?) > + "Download the git repo at URL to file, checked out at REFERENCE. > +REFERENCE must be a pair argument as understood by 'latest-repository-commit'. > +Return FILE." > + ;; TODO: Support recursive repos. > + ;; 'libgit2' doesn't support the URL format generated by 'uri->string' so > + ;; we have to do a little fixup. Dropping completely the 'file:' protocol > + ;; part gives better performance. > > + (let ((url* (cond ((string-prefix? "file://" url) > + (string-drop url (string-length "file://"))) > + ((string-prefix? "file:" url) > + (string-drop url (string-length "file:"))) > + (else url)))) > + (copy-recursively-without-dot-git > + (update-cached-checkout url* #:ref reference #:recursive? recursive?) > + file)) > + file) > + > (define (ensure-valid-store-file-name name) > "Replace any character not allowed in a store name by an underscore." > > @@ -67,17 +124,36 @@ (define valid > name)) > > > -(define* (download-to-store* url #:key (verify-certificate? #t)) > +(define* (download-to-store* url #:key (verify-certificate? #t) #:allow-other-keys) > (with-store store > (download-to-store store url > (ensure-valid-store-file-name (basename url)) > #:verify-certificate? verify-certificate?))) > > +(define* (git-download-to-store* url reference recursive? #:key (verify-certificate? #t)) > + "Download the git repository at URL to the store, checked out at REFERENCE. > +URL must specify a protocol (i.e https:// or file://), REFERENCE must be a > +pair argument as understood by 'latest-repository-commit'." > + ;; Ensure the URL string is properly formatted when using the 'file' protocol: > + ;; URL is generated using 'uri->string', which returns "file:/path/to/file" instead of > + ;; "file:///path/to/file", which in turn makes 'git-download-to-store' fail. > + (let* ((file? (string-prefix? "file:" url)) > + (url* (if (and file? > + (not (string-prefix? "file:///" url))) > + (string-append "file://" (string-replace url "" 0 (string-length "file:"))) > + url))) > + (with-store store > + ;; TODO: Support recursive repos. > + ;; TODO: Verify certificate support and deactivation. > + (latest-repository-commit store url* #:recursive? recursive? #:ref reference)))) > + Some lines look like > 80 chars here. Please break long lines accordingly. > (define %default-options > ;; Alist of default option values. > `((format . ,bytevector->nix-base32-string) > (hash-algorithm . ,(hash-algorithm sha256)) > (verify-certificate? . #t) > + (git-reference . #f) > + (recursive? . #f) > (download-proc . ,download-to-store*))) > > (define (show-help) > @@ -97,6 +173,19 @@ (define (show-help) > do not validate the certificate of HTTPS servers ")) > (format #t (G_ " > -o, --output=FILE download to FILE")) > + (format #t (G_ " > + -g, --git download the default branch's latest commit of the > + git repository at URL")) > + (format #t (G_ " > + --commit=COMMIT_OR_TAG > + download the given commit or tag of the git > + repository at URL")) > + (format #t (G_ " > + --branch=BRANCH download the given branch of the git repository > + at URL")) > + (format #t (G_ " > + -r, --recursive download a git repository recursively")) > + > (newline) > (display (G_ " > -h, --help display this help and exit")) > @@ -105,6 +194,13 @@ (define (show-help) > (newline) > (show-bug-report-information)) > > +(define (add-git-download-option result) > + (alist-cons 'download-proc > + ;; XXX: #:verify-certificate? currently ignored. > + (lambda* (url #:key verify-certificate? ref recursive?) > + (git-download-to-store* url ref recursive?)) > + (alist-delete 'download result))) > + > (define %options > ;; Specifications of the command-line options. > (list (option '(#\f "format") #t #f > @@ -136,11 +232,36 @@ (define fmt-proc > (alist-cons 'verify-certificate? #f result))) > (option '(#\o "output") #t #f > (lambda (opt name arg result) > - (alist-cons 'download-proc > - (lambda* (url #:key verify-certificate?) > - (download-to-file url arg)) > - (alist-delete 'download result)))) > - > + (let* ((git > + (assoc-ref result 'git-reference))) > + (if git > + (alist-cons 'download-proc > + (lambda* (url #:key verify-certificate? ref recursive?) > + (git-download-to-file url arg (assoc-ref result 'git-reference) recursive?)) > + (alist-delete 'download result)) > + (alist-cons 'download-proc > + (lambda* (url #:key verify-certificate? #:allow-other-keys) > + (download-to-file url arg)) > + (alist-delete 'download result)))))) > + (option '(#\g "git") #f #f > + (lambda (opt name arg result) > + ;; Ignore this option if 'commit' or 'branch' has > + ;; already been provided > + (if (assoc-ref result 'git-reference) > + result > + (alist-cons 'git-reference '() > + (add-git-download-option result))))) > + (option '("commit") #t #f > + (lambda (opt name arg result) > + (alist-cons 'git-reference `(tag-or-commit . ,arg) > + (add-git-download-option result)))) > + (option '("branch") #t #f > + (lambda (opt name arg result) > + (alist-cons 'git-reference `(branch . ,arg) > + (alist-delete 'git-reference result)))) > + (option '(#\r "recursive") #f #f > + (lambda (opt name arg result) > + (alist-cons 'recursive? #t result))) > (option '(#\h "help") #f #f > (lambda args > (leave-on-EPIPE (show-help)) > @@ -183,12 +304,13 @@ (define (parse-options) > (terminal-columns))) > (fetch (uri->string uri) > #:verify-certificate? > - (assq-ref opts 'verify-certificate?)))) > - (hash (call-with-input-file > - (or path > - (leave (G_ "~a: download failed~%") > - arg)) > - (cute port-hash (assoc-ref opts 'hash-algorithm) <>))) > + (assq-ref opts 'verify-certificate?) > + #:ref (assq-ref opts 'git-reference) > + #:recursive? (assq-ref opts 'recursive?)))) > + (hash (let* ((path* (or path > + (leave (G_ "~a: download failed~%") > + arg)))) > + (file-hash* path* #:algorithm (assoc-ref opts 'hash-algorithm)))) Here also there are some too long lines in the above hunks; please break long lines so they fit within the 80 characters limit. > (fmt (assq-ref opts 'format))) > (format #t "~a~%~a~%" path (fmt hash)) > #t))) > diff --git a/tests/guix-download.sh b/tests/guix-download.sh > index f4cb335eef..3bf63c4b12 100644 > --- a/tests/guix-download.sh > +++ b/tests/guix-download.sh > @@ -45,4 +45,46 @@ cmp "$output" "$abs_top_srcdir/README" > # This one should fail. > guix download "file:///does-not-exist" "file://$abs_top_srcdir/README" && false > > +# Test git support with local repository Nitpick: please punctuate standalone comments (here, a missing period). > +test_directory="$(mktemp -d)" > +trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory" ; rm -f "$output"' EXIT the 'chmod' doesn't seem to be useful; since we force removing with -f ? And where did the $output variable come from? > + > +# Create a dummy git repo in the temporary directory > +( > + cd $test_directory > + git init > + touch test > + git config user.name "User" > + git config user.email "user@domain" > + git add test > + git commit -m "Commit" > + git tag -a -m "v1" v1 > +) > + > +# Extract commit number > +commit=$((cd $test_directory && git log) | head -n 1 | cut -f2 -d' ') > + > +# We expect that guix hash is working properly or at least that the output of > +# 'guix download' is consistent with 'guix hash' > +expected_hash=$(guix hash -rx $test_directory) > + > +# Test the different options > +for option in "" "--commit=$commit" "--commit=v1" "--branch=master" > +do > + command_output="$(guix download --git $option "file://$test_directory")" > + computed_hash="$(echo $command_output | cut -f2 -d' ')" > + store_path="$(echo $command_output | cut -f1 -d' ')" > + [ "$expected_hash" = "$computed_hash" ] > + diff -r -x ".git" $test_directory $store_path > +done > + > +# Should fail > +guix download --git --branch=non_existent "file://$test_directory" && false > + > +# Same but download to file instead of store > +tmpdir="t-archive-dir-$$" > +trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory" ; rm -f "$output" ; rm -rf "$tmpdir"' EXIT It'd look nicer if there was a single global trap call at the top of these tests. Don't forget to punctuate your comments :-). Otherwise, it looks good to me, although I haven't tried it. -- Thanks, Maxim