diff options
Diffstat (limited to 'pkg/handler')
| -rw-r--r-- | pkg/handler/git/handler.go | 23 | 
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)  } | 
