1
0
Fork 0

Show 10 last commits on summary page

This commit is contained in:
Tom Willemsen 2012-09-20 01:10:17 +02:00
parent 4ad0c3969c
commit a24f7703e6
2 changed files with 43 additions and 7 deletions

View file

@ -42,6 +42,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-last-update
git-latest-commits
munge-tree munge-tree1 parse-commit commit-utc-timestamp
@ -191,6 +192,23 @@
(error "bad line2" line2))
(error "bad line1" line1)))))))
(define* (git-latest-commits rev n #:optional (git-dir *git-dir*))
(let lp ((lines (string-split
(git "--git-dir" (expanduser git-dir)
"rev-list" "--pretty=format:%ar\t%s\t%an"
"-n" (number->string n) rev) #\newline))
(ret '()))
(if (or (null? lines)
(and (null? (cdr lines)) (string-null? (car lines))))
(reverse ret)
(lp (cddr lines)
(let ((line (cadr lines)))
(match-bind
"^([^\t]+)\t([^\t]+)\t(.*)$" line (_ sha1 subject author)
(cons `(,sha1 ,subject ,author) ret)
(error "bad line" line)))))))
(define* (git-last-update #:optional (git-dir *git-dir*))
(let lp ((lines (string-split
(git "--git-dir" (expanduser git-dir)

View file

@ -104,10 +104,28 @@
page-list)))))))
(define* (page-project request body index project page)
(if (file-exists? (string-append *projects-dir* project ".git"))
(respond `(,(project-pages-menu request project (or page "summary"))
(let ((project-dir (string-append *projects-dir* project ".git")))
(if (file-exists? project-dir)
(respond
`(,(project-pages-menu request project (or page "summary"))
(p "Goto: "
(a (@ (href "http://code.ryuslash.org/cgit.cgi/"
,project "/" ,(or page "")))
"cgit " ,(or page "summary")))))
(page-not-found request body index)))
"cgit " ,(or page "summary")))
,@(case (string->symbol page)
((summary)
`((h2 "Last 10 commits")
(table
(@ (class "table table-condensed table-striped"))
(tr
(th "Time")
(th "Subject")
(th "Author"))
,@(map (lambda (elm)
`(tr
(td ,(car elm))
(td ,(cadr elm))
(td ,(caddr elm))))
(git-latest-commits "HEAD" 10 project-dir)))))
(else '()))))
(page-not-found request body index))))