1
0
Fork 0

Add git-last-update

Checks to see how long ago the last update was, returns a string
representing the relative time period.
This commit is contained in:
Tom Willemsen 2012-09-16 15:41:51 +02:00
parent bfed5ed044
commit 10e7025d6f

View file

@ -41,7 +41,7 @@
git git* ensure-git-repo git-ls-tree git-ls-subdirs git git* ensure-git-repo git-ls-tree git-ls-subdirs
git-mktree git-rev-parse git-hash-object git-update-ref git-mktree git-rev-parse git-hash-object git-update-ref
git-commit-tree git-rev-list git-revert git-commit-tree git-rev-list git-revert git-last-update
munge-tree munge-tree1 parse-commit commit-utc-timestamp munge-tree munge-tree1 parse-commit commit-utc-timestamp
@ -191,6 +191,18 @@
(error "bad line2" line2)) (error "bad line2" line2))
(error "bad line1" line1))))))) (error "bad line1" line1)))))))
(define* (git-last-update #:optional (git-dir *git-dir*))
(let lp ((lines (string-split
(git "--git-dir" (expanduser git-dir)
"rev-list" "--pretty=format:%ar" "-n" "1" "HEAD")
#\newline))
(ret '()))
(if (or (null? lines)
(and (null? (cdr lines)) (string-null? (car lines))))
ret
(lp (cddr lines)
(cadr lines)))))
(define (git-hash-object contents) (define (git-hash-object contents)
(string-trim-both (string-trim-both
(git* '("hash-object" "-w" "--stdin") #:input contents))) (git* '("hash-object" "-w" "--stdin") #:input contents)))