Git status wrapper.
This commit is contained in:
parent
afeaa4f28b
commit
fccdf37014
2 changed files with 19 additions and 4 deletions
|
@ -33,7 +33,8 @@
|
|||
|
||||
(import scheme
|
||||
(chicken base)
|
||||
util-io)
|
||||
util-io
|
||||
util-dict-list)
|
||||
|
||||
;; Valid git operating modes
|
||||
(define git-modes
|
||||
|
@ -71,13 +72,26 @@
|
|||
(lambda args
|
||||
(invoke-git repo args))))))
|
||||
|
||||
;; Known status types
|
||||
(define git-status-types
|
||||
'((" M" 'modified)
|
||||
("??" 'untracked)))
|
||||
|
||||
;; Returns a dictionary of unknown, modified, deleted and added files
|
||||
(define (git-status repo)
|
||||
(let loop ((lines ((git repo) 'status '--porcelain))
|
||||
(res (make-ldict)))
|
||||
(if (null? lines)
|
||||
res
|
||||
(loop (cdr lines)
|
||||
res))))
|
||||
(let* ((line (car lines))
|
||||
(st (substring line 0 2))
|
||||
(fname (substring line 4))
|
||||
(status (or (assoc st git-status-types)
|
||||
'unknown)))
|
||||
(loop (cdr lines)
|
||||
(ldict-set res
|
||||
status
|
||||
(cons fname
|
||||
(ldict-ref res status '()))))))))
|
||||
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue