unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 42225@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#42225] [PATCH 3/5] git: Add 'with-git-error-handling'.
Date: Mon,  6 Jul 2020 10:43:54 +0200	[thread overview]
Message-ID: <20200706084356.13013-3-ludo@gnu.org> (raw)
In-Reply-To: <20200706084356.13013-1-ludo@gnu.org>

* 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))
 
 \f
@@ -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))))
-
 \f
 ;;;
 ;;; 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





  parent reply	other threads:[~2020-07-06  8:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06  8:37 [bug#42225] [PATCH 0/5] Add 'guix git-authenticate' command Ludovic Courtès
2020-07-06  8:43 ` [bug#42225] [PATCH 1/5] git-authenticate: Factorize 'authenticate-repository' Ludovic Courtès
2020-07-06  8:43   ` [bug#42225] [PATCH 2/5] Add 'etc/historical-authorizations' Ludovic Courtès
2020-07-06  8:43   ` Ludovic Courtès [this message]
2020-07-06  8:43   ` [bug#42225] [PATCH 4/5] Add 'guix git-authenticate' Ludovic Courtès
2020-07-06  8:43   ` [bug#42225] [PATCH 5/5] maint: Remove 'build-aux/git-authenticate.scm' Ludovic Courtès
2020-07-06  9:24 ` [bug#42225] [PATCH 0/5] Add 'guix git-authenticate' command zimoun
2020-07-06 12:46   ` Ludovic Courtès
2020-07-06 13:27     ` zimoun
2020-07-06 19:48       ` Ludovic Courtès
2020-07-06 21:27         ` zimoun
2020-07-11 11:01           ` bug#42225: " Ludovic Courtès
2020-07-16  0:12             ` [bug#42225] " zimoun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200706084356.13013-3-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=42225@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).