implement commit log! also, tabulate contributors

This commit is contained in:
pho4cexa 2022-12-09 20:55:33 -08:00 committed by m455
parent fecd7af9c3
commit 75b7406508
2 changed files with 27 additions and 6 deletions

View file

@ -58,12 +58,12 @@ TODO
- **documentation/feature**: use post-update rather than post-receive hook for simplicity
- **documentation**: also describe use with post-commit hook
- **feature**: multi-page or collapse-able files list
- **feature**: commit log
- **feature**: branches and releases (tags)
- **feature**: clickable line numbers in source files
- **feature**: customizable templates
- **feature**: display binary files as output from binary-file analysis tools like hexdump, xxd, dumpelf, elfls, readelf, etc.?
- **feature**: syntax highlighting?
- **bug**: markdown-render and/or html-escape git log text
## license: agpl-3.0+

View file

@ -65,6 +65,10 @@ hr {
border-bottom: 1px solid black;
margin-top: 16px;
}
td {
padding: 0em .5em;
vertical-align: top;
}
##file-path {
/* change this to your liking */
}
@ -84,6 +88,7 @@ hr {
(string-append "<a href=\"" relative-root "LICENSE.html\">license</a>"))
((member "LICENSE.md" source-files-list)
(string-append "<a href=\"" relative-root "LICENSE.md.html\">license</a>")))
<a href="#{relative-root}commits.html">commits</a>
<a href="#{relative-root}contributors.html">contributors</a>
</nav>
<hr>
@ -166,14 +171,29 @@ string-block
source-files-list)
(display "</ul>\n"))
(define (display-commits-html)
(SXML->HTML
`((h1 "Commits")
(table
(tr (th "Date") (th "Ref") (th "Log") (th "Author"))
,(map
(lambda (line)
(let-values (((date ref title author) (apply values (string-split line "\t"))))
`(tr (td ,date) (td ,ref) (td ,title) (td ,author))))
(call-with-input-pipe
"git log --format=format:%as%x09%h%x09%s%x09%aN HEAD"
read-lines))))))
(define (display-contributors-html)
(SXML->HTML
`((h1 "Contributors")
(ul ,(map
(lambda (line)
(let-values (((commits . author) (apply values (string-split line "\t"))))
`(li ,author)))
(call-with-input-pipe "git shortlog -ns HEAD" read-lines))))))
(table
(tr (th "Author") (th "Commits"))
,(map
(lambda (line)
(let-values (((commits . author) (apply values (string-split line "\t"))))
`(tr (td ,author) (td ,commits))))
(call-with-input-pipe "git shortlog -ns HEAD" read-lines))))))
(define (first-if pred lst)
(cond ((null? lst) #f)
@ -195,6 +215,7 @@ string-block
;; special files
(write-with-template "files.html" (lambda () (display-files-html source-files-list)))
(write-with-template "contributors.html" display-contributors-html)
(write-with-template "commits.html" display-commits-html)
;; htmlified repo contents
(for-each
(lambda (source-file)