added command structure for git calling
This commit is contained in:
+27
-11
@@ -7,6 +7,7 @@
|
||||
|
||||
(provide cmd-git-status
|
||||
cmd-git-add
|
||||
cmd-git-commit
|
||||
)
|
||||
|
||||
(define (cmd-git-status args)
|
||||
@@ -21,8 +22,10 @@
|
||||
([eq? state 'M] (list 'modified file))
|
||||
([eq? state 'A] (list 'added file))
|
||||
([eq? state 'D] (list 'deleted file))
|
||||
([eq? state 'AM] (list 'modified-added file))
|
||||
([eq? state 'AD] (list 'deleted-added file))
|
||||
([eq? state 'AM] (list 'modified file))
|
||||
([eq? state 'AD] (list 'deleted file))
|
||||
([eq? state 'MM] (list 'modified file))
|
||||
([eq? state 'MD] (list 'deleted file))
|
||||
(else
|
||||
(git-error 'status "Unexpected state" state))
|
||||
)
|
||||
@@ -34,12 +37,25 @@
|
||||
)
|
||||
)
|
||||
|
||||
(define (cmd-git-add args)
|
||||
(let ((output (run-git (cons 'add args))))
|
||||
(let-values (((result out) (git-out 'add output)))
|
||||
(if result
|
||||
(begin
|
||||
(git-displ out)
|
||||
result)
|
||||
(git-error 'add "Error" out)))))
|
||||
|
||||
|
||||
|
||||
|
||||
(define-syntax def-proxy-cmd
|
||||
(syntax-rules ()
|
||||
((_ f cmd)
|
||||
(define (f args)
|
||||
(let ((output (run-git (cons 'cmd args))))
|
||||
(let-values (((result out) (git-out 'cmd output)))
|
||||
(if result
|
||||
(begin
|
||||
(git-displ out)
|
||||
result)
|
||||
(git-error 'cmd "Error" out)))))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(def-proxy-cmd cmd-git-add add)
|
||||
(def-proxy-cmd cmd-git-commit commit)
|
||||
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
|
||||
(define (git-displ out)
|
||||
(let ((str (if (string? out) out (string-join out "\n"))))
|
||||
(info-git str)
|
||||
(when (cfg-get 'git 'display-output #t)
|
||||
(displayln str))))
|
||||
(unless (string=? (string-trim str) "")
|
||||
(info-git str)
|
||||
(when (cfg-get 'git 'display-output #t)
|
||||
(displayln str)))))
|
||||
|
||||
Reference in New Issue
Block a user