From patchwork Mon Jul 6 08:43:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 23077 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 293AE27BBE3; Mon, 6 Jul 2020 09:45:53 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id A48AD27BBE1 for ; Mon, 6 Jul 2020 09:45:52 +0100 (BST) Received: from localhost ([::1]:57168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsMl6-0005L2-6m for patchwork@mira.cbaines.net; Mon, 06 Jul 2020 04:45:52 -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 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * 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