diff options
| author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-06-25 20:37:40 +0200 | 
|---|---|---|
| committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-06-25 20:37:40 +0200 | 
| commit | 907c13566c775ac1210bc66de99f7273e7c8a507 (patch) | |
| tree | b2c3f6a647441d452e8a5c119f7d00dd947b7dff /pkg/handler/git/handler.go | |
| parent | 75d3ee252e7d966055bb76258d3e0da28488d261 (diff) | |
| download | cerrado-907c13566c775ac1210bc66de99f7273e7c8a507.tar.gz cerrado-907c13566c775ac1210bc66de99f7273e7c8a507.tar.bz2 cerrado-907c13566c775ac1210bc66de99f7273e7c8a507.zip | |
feat: Add commit page
Diffstat (limited to 'pkg/handler/git/handler.go')
| -rw-r--r-- | pkg/handler/git/handler.go | 22 | 
1 files changed, 22 insertions, 0 deletions
| diff --git a/pkg/handler/git/handler.go b/pkg/handler/git/handler.go index 0963033..fd62e44 100644 --- a/pkg/handler/git/handler.go +++ b/pkg/handler/git/handler.go @@ -34,6 +34,7 @@ type (  	gitService interface {  		ListRepositories() ([]*service.Repository, error)  		ListCommits(name string, ref string, count int) ([]*object.Commit, error) +		LastCommit(name string, ref string) (*object.Commit, error)  		GetHead(name string) (*plumbing.Reference, error)  		GetTree(name, ref, path string) (*object.Tree, error)  		IsBinary(name, ref, path string) (bool, error) @@ -331,6 +332,27 @@ func (g *GitHandler) Log(w http.ResponseWriter, r *http.Request) error {  	return nil  } +func (g *GitHandler) Commit(w http.ResponseWriter, r *http.Request) error { +	ext.SetHTML(w) +	name := r.PathValue("name") +	ref := r.PathValue("ref") + +	commit, err := g.gitService.LastCommit(name, ref) +	if err != nil { +		return err +	} + +	gitList := &templates.GitItemPage{ +		Name: name, +		Ref:  ref, +		GitItemBase: &templates.GitItemCommitPage{ +			Commit: commit, +		}, +	} +	templates.WritePageTemplate(w, gitList) +	return nil +} +  func GetLexers(filename string) chroma.Lexer {  	if filename == "APKBUILD" {  		return lexers.Get("sh") | 
