Show repository status.

This commit is contained in:
Dominik Pantůček 2023-04-16 21:38:15 +02:00
parent 7a91e8f4f9
commit 67da5d9be1
2 changed files with 33 additions and 15 deletions

View file

@ -41,7 +41,9 @@
util-mail util-mail
logging logging
progress progress
period) period
util-git
util-dict-list)
;; Command-line options and configurable parameters ;; Command-line options and configurable parameters
(define -needs-bank- (make-parameter #f)) (define -needs-bank- (make-parameter #f))
@ -162,6 +164,8 @@
(-notify-months- 3) (-notify-months- 3)
(-needs-bank- #t) (-needs-bank- #t)
(-action- 'notify)) (-action- 'notify))
(-status () "Show members directory status"
(-action- 'status))
) )
;; Print banner ;; Print banner
@ -342,6 +346,17 @@
(make+send-reminder-email (car lst)) (make+send-reminder-email (car lst))
(make+print-reminder-email (car lst))) (make+print-reminder-email (car lst)))
(loop (cdr lst)))))))) (loop (cdr lst))))))))
((status)
(let ((status (git-status (*members-directory*))))
(newline)
(print "Repository " (*members-directory*) " status:")
(if (ldict-ref status 'clean)
(print " Repository up-to-date.")
(let loop ((keys '(unknown untracked modified)))
(when (not (null? keys))
(when (ldict-contains? status (car keys))
(print " " (car keys) ": " (length (ldict-ref status (car keys)))))
(loop (cdr keys)))))))
(else (else
(print "Nothing to do.")) (print "Nothing to do."))

View file

@ -29,6 +29,7 @@
util-git util-git
( (
git git
git-status
) )
(import scheme (import scheme
@ -79,8 +80,10 @@
;; Returns a dictionary of unknown, modified, deleted and added files ;; Returns a dictionary of unknown, modified, deleted and added files
(define (git-status repo) (define (git-status repo)
(let loop ((lines ((git repo) 'status '--porcelain)) (let* ((lines ((git repo) 'status '--porcelain))
(res (make-ldict))) (clean? (null? lines)))
(let loop ((lines lines)
(res (make-ldict `((clean . ,clean?)))))
(if (null? lines) (if (null? lines)
res res
(let* ((line (car lines)) (let* ((line (car lines))
@ -92,6 +95,6 @@
(ldict-set res (ldict-set res
status status
(cons fname (cons fname
(ldict-ref res status '())))))))) (ldict-ref res status '())))))))))
) )