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/GIT/REPOS/")
15 (let ((repo-pathname (make-pathname git-base-dir repo)))
16 (if (not (string-prefix? git-base-dir (normalize-pathname repo-pathname)))
17 (error "Invalid git repository."))
18 (with-current-working-directory
21 (let-values (((in-port out-port id) (process "git" args)))
22 (let ((result (read-lines in-port)))
23 (close-input-port in-port)
24 (close-output-port out-port)
28 (let ((entries (git "ls-tree" branch path))
29 (references (git "show-ref" "--heads")))
32 (conc "Git repository " repo)
34 (conc "(Clone from " git-base-url repo ".)")
36 "-----= Branches =-----")
38 (let ((refname (caddr (string-split ref "/"))))
41 (conc (if (equal? branch refname) "*" "")
43 (conc "browse-git.scm|tree|" repo "|" refname "|" path))))
46 (conc "-----= Files [" path "] =-----"))
48 (let* ((l (string-split entry "\t"))
49 (type (string->symbol (cadr (string-split (car l) " "))))
51 (file (conc (pathname-file file-path)
52 (if (pathname-extension file-path)
53 (conc "." (pathname-extension file-path))
55 (list (if (eq? type 'tree) 1 0)
57 (conc "browse-git.scm|" type "|" repo "|" branch "|"
65 (git "cat-file" "blob" (conc branch ":" path)))
68 (let ((type (string->symbol type-str)))
73 (error "Unsupported git object.")))))