From 998c1777afeeb44ecf6ba2e735a4d6176a9b339e Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sat, 15 Feb 2025 21:18:06 +0100 Subject: feat: Add tag and branch to log Now it is possible to see tag and branch on the log page. --- templates/commit.qtpl | 24 ++++-- templates/commit.qtpl.go | 160 ++++++++++++++++++++++++++++----------- templates/gititemcommit.qtpl | 4 +- templates/gititemcommit.qtpl.go | 4 +- templates/gititemlog.qtpl | 2 +- templates/gititemlog.qtpl.go | 2 +- templates/gititemsummary.qtpl | 2 +- templates/gititemsummary.qtpl.go | 2 +- 8 files changed, 140 insertions(+), 60 deletions(-) (limited to 'templates') diff --git a/templates/commit.qtpl b/templates/commit.qtpl index b5699f4..adc6f2a 100644 --- a/templates/commit.qtpl +++ b/templates/commit.qtpl @@ -1,24 +1,34 @@ +{% import "git.gabrielgio.me/cerrado/pkg/git" %} {% import "git.gabrielgio.me/cerrado/pkg/humanize" %} -{% import "github.com/go-git/go-git/v5/plumbing/object" %} -{% func Commit(name string, c *object.Commit, showTar bool) %} +{% func Commit(name string, c *git.CommitReference, showTar bool) %}
- {%s c.Hash.String()[0:8] %} — - {%s c.Author.Name %} + {%s c.Commit().Hash.String()[0:8] %} — + {%s c.Commit().Author.Name %} + — + {% if c.HasReference() %} + {% for _, r := range c.References() %} + {% if r.Name().IsBranch() %} + {%s r.Name().Short() %} + {% else %} + {%s r.Name().Short() %} + {% endif %} + {% endfor %} + {%endif%}
{% if showTar %} {% endif %}
-
{%s c.Message %}
+
{%s c.Commit().Message %}
{% endfunc %} diff --git a/templates/commit.qtpl.go b/templates/commit.qtpl.go index 75ae899..fda993d 100644 --- a/templates/commit.qtpl.go +++ b/templates/commit.qtpl.go @@ -5,10 +5,10 @@ package templates //line templates/commit.qtpl:1 -import "git.gabrielgio.me/cerrado/pkg/humanize" +import "git.gabrielgio.me/cerrado/pkg/git" //line templates/commit.qtpl:2 -import "github.com/go-git/go-git/v5/plumbing/object" +import "git.gabrielgio.me/cerrado/pkg/humanize" //line templates/commit.qtpl:4 import ( @@ -24,7 +24,7 @@ var ( ) //line templates/commit.qtpl:4 -func StreamCommit(qw422016 *qt422016.Writer, name string, c *object.Commit, showTar bool) { +func StreamCommit(qw422016 *qt422016.Writer, name string, c *git.CommitReference, showTar bool) { //line templates/commit.qtpl:4 qw422016.N().S(`
@@ -32,7 +32,7 @@ func StreamCommit(qw422016 *qt422016.Writer, name string, c *object.Commit, show
`) //line templates/commit.qtpl:8 - qw422016.E().S(c.Hash.String()[0:8]) + qw422016.E().S(c.Commit().Hash.String()[0:8]) //line templates/commit.qtpl:8 qw422016.N().S(``) //line templates/commit.qtpl:9 - qw422016.E().S(c.Author.Name) + qw422016.E().S(c.Commit().Author.Name) //line templates/commit.qtpl:9 qw422016.N().S(` + — + `) +//line templates/commit.qtpl:11 + if c.HasReference() { +//line templates/commit.qtpl:11 + qw422016.N().S(` + `) +//line templates/commit.qtpl:12 + for _, r := range c.References() { +//line templates/commit.qtpl:12 + qw422016.N().S(` + `) +//line templates/commit.qtpl:13 + if r.Name().IsBranch() { +//line templates/commit.qtpl:13 + qw422016.N().S(` + `) +//line templates/commit.qtpl:14 + qw422016.E().S(r.Name().Short()) +//line templates/commit.qtpl:14 + qw422016.N().S(` + `) +//line templates/commit.qtpl:15 + } else { +//line templates/commit.qtpl:15 + qw422016.N().S(` + `) +//line templates/commit.qtpl:16 + qw422016.E().S(r.Name().Short()) +//line templates/commit.qtpl:16 + qw422016.N().S(` + `) +//line templates/commit.qtpl:17 + } +//line templates/commit.qtpl:17 + qw422016.N().S(` + `) +//line templates/commit.qtpl:18 + } +//line templates/commit.qtpl:18 + qw422016.N().S(` + `) +//line templates/commit.qtpl:19 + } +//line templates/commit.qtpl:19 + qw422016.N().S(`
`) -//line templates/commit.qtpl:11 +//line templates/commit.qtpl:21 if showTar { -//line templates/commit.qtpl:11 +//line templates/commit.qtpl:21 qw422016.N().S(` `) -//line templates/commit.qtpl:15 +//line templates/commit.qtpl:25 } -//line templates/commit.qtpl:15 +//line templates/commit.qtpl:25 qw422016.N().S(`
`)
-//line templates/commit.qtpl:21
-	qw422016.E().S(c.Message)
-//line templates/commit.qtpl:21
+//line templates/commit.qtpl:31
+	qw422016.E().S(c.Commit().Message)
+//line templates/commit.qtpl:31
 	qw422016.N().S(`
`) -//line templates/commit.qtpl:24 +//line templates/commit.qtpl:34 } -//line templates/commit.qtpl:24 -func WriteCommit(qq422016 qtio422016.Writer, name string, c *object.Commit, showTar bool) { -//line templates/commit.qtpl:24 +//line templates/commit.qtpl:34 +func WriteCommit(qq422016 qtio422016.Writer, name string, c *git.CommitReference, showTar bool) { +//line templates/commit.qtpl:34 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/commit.qtpl:24 +//line templates/commit.qtpl:34 StreamCommit(qw422016, name, c, showTar) -//line templates/commit.qtpl:24 +//line templates/commit.qtpl:34 qt422016.ReleaseWriter(qw422016) -//line templates/commit.qtpl:24 +//line templates/commit.qtpl:34 } -//line templates/commit.qtpl:24 -func Commit(name string, c *object.Commit, showTar bool) string { -//line templates/commit.qtpl:24 +//line templates/commit.qtpl:34 +func Commit(name string, c *git.CommitReference, showTar bool) string { +//line templates/commit.qtpl:34 qb422016 := qt422016.AcquireByteBuffer() -//line templates/commit.qtpl:24 +//line templates/commit.qtpl:34 WriteCommit(qb422016, name, c, showTar) -//line templates/commit.qtpl:24 +//line templates/commit.qtpl:34 qs422016 := string(qb422016.B) -//line templates/commit.qtpl:24 +//line templates/commit.qtpl:34 qt422016.ReleaseByteBuffer(qb422016) -//line templates/commit.qtpl:24 +//line templates/commit.qtpl:34 return qs422016 -//line templates/commit.qtpl:24 +//line templates/commit.qtpl:34 } diff --git a/templates/gititemcommit.qtpl b/templates/gititemcommit.qtpl index ec67757..7de1bdb 100644 --- a/templates/gititemcommit.qtpl +++ b/templates/gititemcommit.qtpl @@ -1,8 +1,8 @@ -{% import "github.com/go-git/go-git/v5/plumbing/object" %} +{% import "git.gabrielgio.me/cerrado/pkg/git" %} {% code type GitItemCommitPage struct { - Commit *object.Commit + Commit *git.CommitReference Diff []byte } %} diff --git a/templates/gititemcommit.qtpl.go b/templates/gititemcommit.qtpl.go index 7e458f3..b790220 100644 --- a/templates/gititemcommit.qtpl.go +++ b/templates/gititemcommit.qtpl.go @@ -5,7 +5,7 @@ package templates //line templates/gititemcommit.qtpl:1 -import "github.com/go-git/go-git/v5/plumbing/object" +import "git.gabrielgio.me/cerrado/pkg/git" //line templates/gititemcommit.qtpl:3 import ( @@ -22,7 +22,7 @@ var ( //line templates/gititemcommit.qtpl:4 type GitItemCommitPage struct { - Commit *object.Commit + Commit *git.CommitReference Diff []byte } diff --git a/templates/gititemlog.qtpl b/templates/gititemlog.qtpl index 93efb24..391de53 100644 --- a/templates/gititemlog.qtpl +++ b/templates/gititemlog.qtpl @@ -13,7 +13,7 @@ type GitItemLogPage struct { {% func (g *GitItemLogPage) GitContent(name, ref string) %}
{% for _, c := range g.Commits %} - {%= Commit(name, c.Commit(), false) %} + {%= Commit(name, c, false) %} {% endfor %} {% if g.Next != nil %} Next diff --git a/templates/gititemlog.qtpl.go b/templates/gititemlog.qtpl.go index 05950ed..2c9ce93 100644 --- a/templates/gititemlog.qtpl.go +++ b/templates/gititemlog.qtpl.go @@ -74,7 +74,7 @@ func (g *GitItemLogPage) StreamGitContent(qw422016 *qt422016.Writer, name, ref s qw422016.N().S(` `) //line templates/gititemlog.qtpl:16 - StreamCommit(qw422016, name, c.Commit(), false) + StreamCommit(qw422016, name, c, false) //line templates/gititemlog.qtpl:16 qw422016.N().S(` `) diff --git a/templates/gititemsummary.qtpl b/templates/gititemsummary.qtpl index 5d07680..e00c37d 100644 --- a/templates/gititemsummary.qtpl +++ b/templates/gititemsummary.qtpl @@ -38,7 +38,7 @@ type GitItemSummaryPage struct {
{% for _, c := range g.Commits %} - {%= Commit(name, c.Commit(), false) %} + {%= Commit(name, c, false) %} {% endfor %}
diff --git a/templates/gititemsummary.qtpl.go b/templates/gititemsummary.qtpl.go index e17ec7c..0a78258 100644 --- a/templates/gititemsummary.qtpl.go +++ b/templates/gititemsummary.qtpl.go @@ -139,7 +139,7 @@ func (g *GitItemSummaryPage) StreamGitContent(qw422016 *qt422016.Writer, name, r qw422016.N().S(` `) //line templates/gititemsummary.qtpl:41 - StreamCommit(qw422016, name, c.Commit(), false) + StreamCommit(qw422016, name, c, false) //line templates/gititemsummary.qtpl:41 qw422016.N().S(` `) -- cgit v1.2.3