Improved git browser example.
authorTim Vaughan <tgvaughan@gmail.com>
Sun, 9 Jun 2019 20:01:44 +0000 (22:01 +0200)
committerTim Vaughan <tgvaughan@gmail.com>
Sun, 9 Jun 2019 20:01:44 +0000 (22:01 +0200)
examples/browse-git.scm

index f9cd019..75b940c 100755 (executable)
@@ -26,7 +26,8 @@
 
   (define (serve-tree)
     (let ((entries (git "ls-tree" branch path))
-          (references (git "show-ref" "--heads")))
+          (references (git "show-ref" "--heads"))
+          (commits (git "rev-list" "--abbrev-commit" "-n5" branch)))
       (append
        (list
         (conc "Git repository " repo)
                        refname)
                  (conc "browse-git.scm|tree|" repo "|" refname "|" path))))
             references)
-       (list ""
-             (conc "-----= Files [" path "] =-----"))
+       (list
+        ""
+        (conc "-----= Recent Commits [" branch "] =-----"))
+       (map (lambda (commit)
+              (list
+               1
+               (conc (if (equal? branch commit) "*" "")
+                     (car (git "show" "-s" "--format=%s (%ar)" commit)))
+               (conc "browse-git.scm|tree|" repo "|" commit "|" path)))
+            commits)
+       (list
+        ""
+        (conc "-----= Files [" path "] =-----"))
        (map (lambda (entry)
               (let* ((l (string-split entry "\t"))
                      (type (string->symbol (cadr (string-split (car l) " "))))