git-preview @ main

static git web frontend but with images and html previews + code truncation

routes: refs view
Mon, 12 Dec 2022
4 files changed, 104 insertions(+), 0 deletions(-)
M git/git.go

@@ -78,3 +78,35 @@ }

return file.Contents() } + +func (g *GitRepo) Tags() ([]*object.Tag, error) { + ti, err := g.r.TagObjects() + if err != nil { + return nil, fmt.Errorf("tag objects: %w", err) + } +

… preview truncated

M routes/handler.go

@@ -21,5 +21,6 @@ mux.HandleFunc("/:name/tree/:ref/...", d.RepoTree, "GET")

mux.HandleFunc("/:name/blob/:ref/...", d.FileContent, "GET") mux.HandleFunc("/:name/log/:ref", d.Log, "GET") mux.HandleFunc("/:name/commit/:ref", d.Diff, "GET") + mux.HandleFunc("/:name/refs", d.Refs, "GET") return mux }
M routes/routes.go

@@ -216,3 +216,42 @@ log.Println(err)

return } } + +func (d *deps) Refs(w http.ResponseWriter, r *http.Request) { + name := flow.Param(r.Context(), "name") + + path := filepath.Join(d.c.Git.ScanPath, name) + gr, err := git.Open(path, "") + if err != nil {

… preview truncated

… and 1 more changed files not shown in this preview