summaryrefslogtreecommitdiff
path: root/tissue
diff options
context:
space:
mode:
authorArun Isaac2023-01-28 23:44:40 +0000
committerArun Isaac2023-01-28 23:46:33 +0000
commit788d02865aa0a0e776ed65defbbd584a236dfdfb (patch)
tree7329cd03b1e1e885245aba5fcaadbb54e128fd65 /tissue
parent27713acc8b03bcbf87c60e563db37b2841a36ab3 (diff)
downloadtissue-788d02865aa0a0e776ed65defbbd584a236dfdfb.tar.gz
tissue-788d02865aa0a0e776ed65defbbd584a236dfdfb.tar.lz
tissue-788d02865aa0a0e776ed65defbbd584a236dfdfb.zip
git: Abstract temporary checkout.
* tissue/git.scm (call-with-temporary-checkout, call-with-temporary-checkouts): New public functions. * .dir-locals.el (scheme-mode): Set scheme-indent-function of call-with-temporary-checkout and call-with-temporary-checkouts to 1.
Diffstat (limited to 'tissue')
-rw-r--r--tissue/git.scm23
1 files changed, 22 insertions, 1 deletions
diff --git a/tissue/git.scm b/tissue/git.scm
index 562e715..653f8ae 100644
--- a/tissue/git.scm
+++ b/tissue/git.scm
@@ -47,7 +47,9 @@
git-tracked-files
call-with-file-in-git
file-modification-table
- clone-options))
+ clone-options
+ call-with-temporary-checkout
+ call-with-temporary-checkouts))
;; We bind additional functions from libgit2 that are not already
;; bound in guile-git. TODO: Contribute them to guile-git.
@@ -211,3 +213,22 @@ that modified them."
'bare
(if bare? 1 0))
clone-options))
+
+(define (call-with-temporary-checkout repository proc)
+ "Call PROC with a temporary checkout of REPOSITORY, and delete the
+checkout when PROC returns or exits non-locally."
+ (call-with-temporary-directory
+ (lambda (temporary-checkout)
+ (clone repository temporary-checkout)
+ (proc temporary-checkout))))
+
+(define (call-with-temporary-checkouts repositories proc)
+ "Call PROC with temporary checkouts of REPOSITORIES, and delete the
+checkouts when PROC returns or exits non-locally."
+ (match repositories
+ ((repository other-repositories ...)
+ (call-with-temporary-checkout repository
+ (lambda (checkout)
+ (call-with-temporary-checkouts other-repositories
+ (cut proc checkout <...>)))))
+ (() (proc))))