From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mathieu Othacehe Subject: bug#38320: Cuirass: Allow to use authenticated Git repositories as inputs Date: Wed, 05 Feb 2020 09:45:09 +0100 Message-ID: <87v9oltobu.fsf@gmail.com> References: <875zjc8ciz.fsf@lassieur.org> <878so4t6mk.fsf@gmail.com> <87r21v9cmi.fsf@gnu.org> <87h829sb73.fsf@gmail.com> <877e34z24m.fsf@gnu.org> <87wob3xepy.fsf@gmail.com> <87zhfyvppi.fsf@lassieur.org> <8736dp8z2p.fsf@gnu.org> <87tv4667b4.fsf@gmail.com> <87v9omy0es.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:36543) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1izGJv-00064H-IQ for bug-guix@gnu.org; Wed, 05 Feb 2020 03:46:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1izGJu-0007Vv-AH for bug-guix@gnu.org; Wed, 05 Feb 2020 03:46:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:39138) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1izGJu-0007Va-6P for bug-guix@gnu.org; Wed, 05 Feb 2020 03:46:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1izGJu-0005Xf-4f for bug-guix@gnu.org; Wed, 05 Feb 2020 03:46:02 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-reply-to: <87v9omy0es.fsf@gnu.org> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane-mx.org@gnu.org Sender: "bug-Guix" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 38320@debbugs.gnu.org, Erik Edrosa , =?UTF-8?Q?Cl=C3=A9ment?= Lassieur --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hey Ludo, Thanks for reviewing :) > It LGTM, and I like that it=E2=80=99s actually a small patch. > > Until now, we had conditionals like the =E2=80=98module-defined?=E2=80=99= thing above to > allow for a smooth transition from older Guile-Git versions. Do we want > to keep doing that? > > If we do, then perhaps you should arrange so that uses of the new > Guile-Git APIs that appeared in 0.3.0 are conditional. > > I=E2=80=99d say we should do it if it=E2=80=99s easy to do and not too in= trusive. > Otherwise, let=E2=80=99s just require 0.3.0 and be done with it. (=E2=80= =98guix pull=E2=80=99 > gets 0.3.0 anyway.) Here's a version with optional authentication support. I do not find it too intrusive, but let me know what you think! Thanks, Mathieu --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-git-Add-ssh-authentication-support.patch Content-Transfer-Encoding: quoted-printable >From 4554baf59564eb0c31cfe235acd078d54afef6d7 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Mon, 3 Feb 2020 18:05:02 +0100 Subject: [PATCH] git: Add ssh authentication support. SSH agent authentication method is used. * guix/git.scm (auth-method): New variable, (clone*): pass previous variable in clone options, (update-cached-checkout): pass previous variable in fetch options. --- guix/git.scm | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/guix/git.scm b/guix/git.scm index a12f1eec8e..2165e612f1 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright =C2=A9 2017 Mathieu Othacehe +;;; Copyright =C2=A9 2017, 2020 Mathieu Othacehe ;;; Copyright =C2=A9 2018, 2019, 2020 Ludovic Court=C3=A8s ;;; ;;; This file is part of GNU Guix. @@ -108,6 +108,14 @@ the 'SSL_CERT_FILE' and 'SSL_CERT_DIR' environment var= iables." (string-append "R:" url) url)))))) =20 +;; Authentication appeared in Guile-Git 0.3.0, check if it is available. +(define auth-supported? + (false-if-exception (resolve-interface '(git auth)))) + +;; Default authentication method. +(define auth-method (and auth-supported? + (%make-auth-ssh-agent))) + (define (clone* url directory) "Clone git repository at URL into DIRECTORY. Upon failure, make sure no empty directory is left behind." @@ -119,7 +127,11 @@ make sure no empty directory is left behind." ;; value in Guile-Git: . (if (module-defined? (resolve-interface '(git)) 'clone-init-options) - (clone url directory (clone-init-options)) + (clone url directory + (if auth-supported? + (make-clone-options + #:fetch-options (make-fetch-options auth-method)) + (clone-init-options))) (clone url directory))) (lambda _ (false-if-exception (rmdir directory))))) @@ -281,7 +293,10 @@ When RECURSIVE? is true, check out submodules as well,= if any." ;; Only fetch remote if it has not been cloned just before. (when (and cache-exists? (not (reference-available? repository ref))) - (remote-fetch (remote-lookup repository "origin"))) + (if auth-supported? + (remote-fetch (remote-lookup repository "origin") + #:fetch-options (make-fetch-options auth-method)) + (remote-fetch (remote-lookup repository "origin")))) (when recursive? (update-submodules repository #:log-port log-port)) (let ((oid (switch-to-ref repository canonical-ref))) --=20 2.25.0 --=-=-=--