From 10e7025d6f9621cfc5c7cf5121c410bd1f90c756 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Sun, 16 Sep 2012 15:41:51 +0200 Subject: Add git-last-update Checks to see how long ago the last update was, returns a string representing the relative time period. --- tekuti/git.scm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tekuti/git.scm b/tekuti/git.scm index 3c9df31..0fe3bd4 100644 --- a/tekuti/git.scm +++ b/tekuti/git.scm @@ -41,7 +41,7 @@ git git* ensure-git-repo git-ls-tree git-ls-subdirs 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 @@ -191,6 +191,18 @@ (error "bad line2" line2)) (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) (string-trim-both (git* '("hash-object" "-w" "--stdin") #:input contents))) -- cgit v1.2.3-54-g00ecf