Initial import of rash-git-cli

This commit is contained in:
2026-08-17 22:00:11 +02:00
parent 6dfcc30427
commit 7dbac023bb
7 changed files with 213 additions and 14 deletions
+64
View File
@@ -0,0 +1,64 @@
#lang racket
(require rackunit
racket/file
linea/read)
(define tmp (make-temporary-file "rash-git-cli~a" 'directory))
(dynamic-wind
void
(λ ()
(define module-path (build-path tmp "Rash.rkt"))
(call-with-output-file module-path
#:exists 'truncate/replace
(λ (out)
(displayln "#lang rash" out)
(displayln "(require rash-git-cli)" out)))
(define module-name `(file ,(path->string module-path)))
(parameterize ([current-directory tmp])
(dynamic-require module-name #f))
(define ns (module->namespace module-name))
(parameterize ([current-directory tmp]
[current-namespace ns])
;; In expression mode the same binding remains callable as git-cli's
;; first-class Git procedure.
(check-true (eval #'(procedure? git)))
;; The Rash line form initializes a repository.
(define init-line
(linea-read-syntax 'drracket-interaction
(open-input-string "git init\n")))
(eval init-line)
(check-true (directory-exists? (build-path tmp ".git")))
(check-true (eval #'(git 'config 'set! "user.name" "Rash Test")))
(check-true (eval #'(git 'config 'set! "user.email" "rash@example.invalid")))
(call-with-output-file (build-path tmp "test.txt")
#:exists 'truncate/replace
(λ (out)
(displayln "rash" out)))
(eval
(linea-read-syntax 'drracket-interaction
(open-input-string "git add test.txt\n")))
(check-true
(eval
(linea-read-syntax 'drracket-interaction
(open-input-string
"git commit -m \"Rash commit\"\n"))))
(check-equal?
(eval
(linea-read-syntax 'drracket-interaction
(open-input-string "git status\n")))
'())
(check-equal? (eval #'(git 'status)) '())))
(λ ()
(delete-directory/files tmp #:must-exist? #f)))