From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id uMMsObrkAl9DagAA0tVLHw (envelope-from ) for ; Mon, 06 Jul 2020 08:45:46 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id iPEUNbrkAl/RZgAAB5/wlQ (envelope-from ) for ; Mon, 06 Jul 2020 08:45:46 +0000 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 822AB9400B7 for ; Mon, 6 Jul 2020 08:45:46 +0000 (UTC) Received: from localhost ([::1]:57168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsMky-0005L2-R8 for larch@yhetil.org; Mon, 06 Jul 2020 04:45:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsMkJ-0004cZ-1l for guix-patches@gnu.org; Mon, 06 Jul 2020 04:45:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50266) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jsMkI-0000bk-OS for guix-patches@gnu.org; Mon, 06 Jul 2020 04:45:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jsMkI-0005r7-NE for guix-patches@gnu.org; Mon, 06 Jul 2020 04:45:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#42225] [PATCH 3/5] git: Add 'with-git-error-handling'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 06 Jul 2020 08:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42225 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 42225@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 42225-submit@debbugs.gnu.org id=B42225.159402505322392 (code B ref 42225); Mon, 06 Jul 2020 08:45:02 +0000 Received: (at 42225) by debbugs.gnu.org; 6 Jul 2020 08:44:13 +0000 Received: from localhost ([127.0.0.1]:33571 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jsMjU-0005p5-MM for submit@debbugs.gnu.org; Mon, 06 Jul 2020 04:44:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51360) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jsMjR-0005oJ-LF for 42225@debbugs.gnu.org; Mon, 06 Jul 2020 04:44:10 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:50386) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsMjM-0000TW-CM; Mon, 06 Jul 2020 04:44:04 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=50318 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jsMjL-0000pX-RN; Mon, 06 Jul 2020 04:44:04 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Mon, 6 Jul 2020 10:43:54 +0200 Message-Id: <20200706084356.13013-3-ludo@gnu.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200706084356.13013-1-ludo@gnu.org> References: <20200706084356.13013-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) 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" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 3.99 X-TUID: LKOukSEUr1+K * guix/scripts/pull.scm (report-git-error, with-git-error-handling): Move to... * guix/git.scm: ... here. * guix/scripts/time-machine.scm: Adjust accordingly. --- guix/git.scm | 19 +++++++++++++++++++ guix/scripts/pull.scm | 18 ------------------ guix/scripts/time-machine.scm | 4 +++- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/guix/git.scm b/guix/git.scm index 0d8e617cc9..19c1cb59d3 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -29,6 +29,7 @@ #:use-module (guix records) #:use-module (guix gexp) #:use-module (guix sets) + #:use-module ((guix diagnostics) #:select (leave)) #:use-module (rnrs bytevectors) #:use-module (ice-9 match) #:use-module (srfi srfi-1) @@ -39,6 +40,7 @@ honor-system-x509-certificates! with-repository + with-git-error-handling false-if-git-not-found update-cached-checkout url+commit->name @@ -209,6 +211,23 @@ dynamic extent of EXP." (call-with-repository directory (lambda (repository) exp ...))) +(define (report-git-error error) + "Report the given Guile-Git error." + ;; Prior to Guile-Git commit b6b2760c2fd6dfaa5c0fedb43eeaff06166b3134, + ;; errors would be represented by integers. + (match error + ((? integer? error) ;old Guile-Git + (leave (G_ "Git error ~a~%") error)) + ((? git-error? error) ;new Guile-Git + (leave (G_ "Git error: ~a~%") (git-error-message error))))) + +(define-syntax-rule (with-git-error-handling body ...) + (catch 'git-error + (lambda () + body ...) + (lambda (key err) + (report-git-error err)))) + (define (load-git-submodules) "Attempt to load (git submodules), which was missing until Guile-Git 0.2.0. Return true on success, false on failure." diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index f953957161..807daec593 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -63,7 +63,6 @@ #:re-export (display-profile-content channel-commit-hyperlink) #:export (channel-list - with-git-error-handling guix-pull)) @@ -464,23 +463,6 @@ true, display what would be built without actually building it." (unless (honor-system-x509-certificates!) (honor-lets-encrypt-certificates! store))) -(define (report-git-error error) - "Report the given Guile-Git error." - ;; Prior to Guile-Git commit b6b2760c2fd6dfaa5c0fedb43eeaff06166b3134, - ;; errors would be represented by integers. - (match error - ((? integer? error) ;old Guile-Git - (leave (G_ "Git error ~a~%") error)) - ((? git-error? error) ;new Guile-Git - (leave (G_ "Git error: ~a~%") (git-error-message error))))) - -(define-syntax-rule (with-git-error-handling body ...) - (catch 'git-error - (lambda () - body ...) - (lambda (key err) - (report-git-error err)))) - ;;; ;;; Profile. diff --git a/guix/scripts/time-machine.scm b/guix/scripts/time-machine.scm index f9bcec651a..441673b780 100644 --- a/guix/scripts/time-machine.scm +++ b/guix/scripts/time-machine.scm @@ -24,10 +24,12 @@ #:use-module (guix channels) #:use-module (guix store) #:use-module (guix status) + #:use-module ((guix git) + #:select (with-git-error-handling)) #:use-module ((guix utils) #:select (%current-system)) #:use-module ((guix scripts pull) - #:select (with-git-error-handling channel-list)) + #:select (channel-list)) #:use-module ((guix scripts build) #:select (%standard-build-options show-build-options-help -- 2.26.2