aboutsummaryrefslogtreecommitdiff
path: root/pkg/handler
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-06-01 18:24:22 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-06-01 18:24:22 +0200
commitf1643ffcbd543cacfe9ab5e46eafdd0c39cd47fd (patch)
treea24d3cbb625f642c25cdc14124b8971fa9bfeb04 /pkg/handler
parent4ea63e98cc999ab05d1ac98b64875d7413e86972 (diff)
downloadcerrado-f1643ffcbd543cacfe9ab5e46eafdd0c39cd47fd.tar.gz
cerrado-f1643ffcbd543cacfe9ab5e46eafdd0c39cd47fd.tar.bz2
cerrado-f1643ffcbd543cacfe9ab5e46eafdd0c39cd47fd.zip
feat: Add refs page
UI now it is a broken state. I'll all pages working first so I can better style it later.
Diffstat (limited to 'pkg/handler')
-rw-r--r--pkg/handler/git/handler.go23
1 files changed, 21 insertions, 2 deletions
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)
}