From f1643ffcbd543cacfe9ab5e46eafdd0c39cd47fd Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sat, 1 Jun 2024 18:24:22 +0200 Subject: feat: Add refs page UI now it is a broken state. I'll all pages working first so I can better style it later. --- pkg/handler/git/handler.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'pkg/handler/git/handler.go') diff --git a/pkg/handler/git/handler.go b/pkg/handler/git/handler.go index ebfb37f..d090f22 100644 --- a/pkg/handler/git/handler.go +++ b/pkg/handler/git/handler.go @@ -6,6 +6,7 @@ import ( "git.gabrielgio.me/cerrado/pkg/service" "git.gabrielgio.me/cerrado/templates" + "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/object" "github.com/gorilla/mux" ) @@ -18,6 +19,8 @@ type ( gitService interface { ListRepositories() ([]*service.Repository, error) ListCommits(string) ([]*object.Commit, error) + ListTags(string) ([]*object.Tag, error) + ListBranches(string) ([]*plumbing.Reference, error) } ) @@ -58,9 +61,25 @@ func (g *GitHandler) About(w http.ResponseWriter, r *http.Request) { func (g *GitHandler) Refs(w http.ResponseWriter, r *http.Request) { name := mux.Vars(r)["name"] + + tags, err := g.gitService.ListTags(name) + if err != nil { + slog.Error("Error loading tags", "error", err) + return + } + + branches, err := g.gitService.ListBranches(name) + if err != nil { + slog.Error("Error loading branches", "error", err) + return + } + gitList := &templates.GitItemPage{ - Name: name, - GitItemBase: &templates.GitItemRefsPage{}, + Name: name, + GitItemBase: &templates.GitItemRefsPage{ + Tags: tags, + Branches: branches, + }, } templates.WritePageTemplate(w, gitList) } -- cgit v1.2.3