all repos — elgit @ 703d2e603629535d3e46413aa60f8bd39a9ef720

fork of legit: web frontend for git, written in go

Merge branch 'feat/add_log_reference'

Alan Pearce
commit

703d2e603629535d3e46413aa60f8bd39a9ef720

parent

98fa355025227a03b4c3c19fc151a4d73479ab49

1 file changed, 15 insertions(+), 3 deletions(-)

changed files
M templates/log.gotemplates/log.go
@@ -3,19 +3,20 @@
import ( "fmt" - "github.com/go-git/go-git/v5/plumbing/object" + "github.com/go-git/go-git/v5/plumbing" + "go.alanpearce.eu/elgit/git" g "go.alanpearce.eu/gomponents" . "go.alanpearce.eu/gomponents/html" ) // Log renders the commit log page -func Log(data PageData, commits []*object.Commit) g.Node { +func Log(data PageData, commits []*git.CommitReference) g.Node { return Page(data, []g.Node{ RepoHeader(data), RenderNav(data), Main( Div(Class("log"), - g.Map(commits, func(commit *object.Commit) g.Node { + g.Map(commits, func(commit *git.CommitReference) g.Node { return g.Group{ Div( Div(
@@ -23,6 +24,17 @@ A(
Href(fmt.Sprintf("/%s/commit/%s", data.Name, commit.Hash.String())), Class("commit-hash"), g.Text(commit.Hash.String()[:8]), + ), + g.Text(" "), + g.If( + commit.HasReference(), + g.Map(commit.References(), func(ref *plumbing.Reference) g.Node { + return A( + Href(fmt.Sprintf("/%s/tree/%s", data.Name, ref.Name().Short())), + Class("commit-hash"), + g.Text(ref.Name().Short()), + ) + }), ), ), Pre(g.Text(commit.Message)),