mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
git: Add 'with-git-error-handling'.
* guix/scripts/pull.scm (report-git-error, with-git-error-handling): Move to... * guix/git.scm: ... here. * guix/scripts/time-machine.scm: Adjust accordingly.
This commit is contained in:
parent
4b9b8b2ec2
commit
69db2993b5
3 changed files with 22 additions and 19 deletions
19
guix/git.scm
19
guix/git.scm
|
@ -29,6 +29,7 @@ (define-module (guix git)
|
|||
#: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 @@ (define-module (guix git)
|
|||
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 @@ (define-syntax-rule (with-repository directory repository 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."
|
||||
|
|
|
@ -63,7 +63,6 @@ (define-module (guix scripts pull)
|
|||
#:re-export (display-profile-content
|
||||
channel-commit-hyperlink)
|
||||
#:export (channel-list
|
||||
with-git-error-handling
|
||||
guix-pull))
|
||||
|
||||
|
||||
|
@ -464,23 +463,6 @@ (define (honor-x509-certificates store)
|
|||
(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.
|
||||
|
|
|
@ -24,10 +24,12 @@ (define-module (guix scripts time-machine)
|
|||
#: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
|
||||
|
|
Loading…
Reference in a new issue