1 ;; Script to browse locally-hosted URLs
3 (lambda (type-str repo branch path)
4 (import (chicken string)
10 (define git-base-url "git://MY.GIT.SERVER/")
11 (define git-base-dir "/PATH/TO/REPOS/")
14 (with-current-working-directory
15 (list git-base-dir repo)
17 (let-values (((in-port out-port id) (process "git" args)))
18 (let ((result (read-lines in-port)))
19 (close-input-port in-port)
20 (close-output-port out-port)
24 (let ((entries (git "ls-tree" branch path))
25 (references (git "show-ref" "--heads")))
28 (conc "Git repository " repo)
30 (conc "(Clone from " git-base-url repo ".)")
32 "-----= Branches =-----")
34 (let ((refname (caddr (string-split ref "/"))))
37 (conc (if (equal? branch refname) "*" "")
39 (conc "browse-git.scm|tree|" repo "|" refname "|" path))))
42 (conc "-----= Files [" path "] =-----"))
44 (let* ((l (string-split entry "\t"))
45 (type (string->symbol (cadr (string-split (car l) " "))))
47 (file (conc (pathname-file file-path)
48 (if (pathname-extension file-path)
49 (conc "." (pathname-extension file-path))
51 (list (if (eq? type 'tree) 1 0)
53 (conc "browse-git.scm|" type "|" repo "|" branch "|"
55 (if (eq? type 'tree) "/" "")))))
62 (git "cat-file" "blob" (conc branch "|" path)))
65 (let ((type (string->symbol type-str)))
70 (error "Unsupported git object.")))))