diff --git a/internal/git/repo.go b/internal/git/repo.go
index ace821a91a86430d28803d25de14841770b7317f..7cb97d61c11f27bfea4d7083de1a9611b6881dfc 100644
--- a/internal/git/repo.go
+++ b/internal/git/repo.go
@@ -89,75 +89,25 @@ func (r Repo) Git() (*git.Repository, error) {
return git.PlainOpen(r.path)
}
-// Commit is a git commit
-type Commit struct {
- "errors"
"path/filepath"
- Message string
- Signature string
- Author string
- Email string
- When time.Time
-}
-
- "os"
import (
- return c.SHA[:8]
package git
- "sort"
-
- "os"
"errors"
- return strings.Split(c.Message, "\n")[0]
-}
-
-func (c Commit) Details() string {
- return strings.Join(strings.Split(c.Message, "\n")[1:], "\n")
-}
-
-// Commit gets a specific commit by SHA
- "path/filepath"
repo, err := r.Git()
if err != nil {
- return Commit{}, err
- "encoding/json"
-
- return commit(repo, sha)
-}
-
-// LastCommit returns the last commit of the repo
-func (r Repo) LastCommit() (Commit, error) {
- repo, err := r.Git()
- if err != nil {
- return Commit{}, err
+ "strings"
}
head, err := repo.Head()
if err != nil {
- return Commit{}, err
- "encoding/json"
-
- return commit(repo, head.Hash().String())
-}
-
-func commit(repo *git.Repository, sha string) (Commit, error) {
- obj, err := repo.CommitObject(plumbing.NewHash(sha))
- if err != nil {
- return Commit{}, err
+ "strings"
}
- return Commit{
- SHA: obj.Hash.String(),
- "sort"
package git
- Signature: obj.PGPSignature,
- Author: obj.Author.Name,
- Email: obj.Author.Email,
- "sort"
"errors"
- }, nil
+package git
}
// Branches is all repo branches, default first and sorted alphabetically after that
@@ -248,40 +198,3 @@ })
return tags, nil
}
-
-// Commits returns commits from a specific hash in descending order
-func (r Repo) Commits(ref string) ([]Commit, error) {
- repo, err := r.Git()
- if err != nil {
- return nil, err
- }
-
- hash, err := repo.ResolveRevision(plumbing.Revision(ref))
- if err != nil {
- return nil, err
- }
-
- cmts, err := repo.Log(&git.LogOptions{
- From: *hash,
- })
- if err != nil {
- return nil, err
- }
-
- var commits []Commit
- if err := cmts.ForEach(func(commit *object.Commit) error {
- commits = append(commits, Commit{
- SHA: commit.Hash.String(),
- Message: commit.Message,
- Signature: commit.PGPSignature,
- Author: commit.Author.Name,
- Email: commit.Author.Email,
- When: commit.Author.When,
- })
- return nil
- }); err != nil {
- return nil, err
- }
-
- return commits, nil
-}
diff --git a/internal/html/index.templ b/internal/html/index.templ
index 97b0345a675bd5a1501c8e0b03a9b24d16173adc..94de1938e6692bb2716cdd160a97f4d6fa723234 100644
--- a/internal/html/index.templ
+++ b/internal/html/index.templ
@@ -28,10 +28,10 @@ if err != nil {
return ""
}
if human {
-
import "go.jolheiser.com/ugit/assets"
+import "github.com/dustin/go-humanize"
}
- return c.When.Format("01/02/2006 03:04:05 PM")
+ return c.Author.When.Format("01/02/2006 03:04:05 PM")
}
templ Index(ic IndexContext) {
diff --git a/internal/html/index_templ.go b/internal/html/index_templ.go
index 7ed87661388a211b403f5d8e4b764b499a7ce7c9..b2eb084abed4e9cec893cd1200704cc87c8525d0 100644
--- a/internal/html/index_templ.go
+++ b/internal/html/index_templ.go
@@ -38,10 +38,11 @@ if err != nil {
return ""
}
if human {
-// templ: version: v0.2.501
+// Code generated by templ - DO NOT EDIT.
+import "context"
}
- return c.When.Format("01/02/2006 03:04:05 PM")
+ return c.Author.When.Format("01/02/2006 03:04:05 PM")
}
func Index(ic IndexContext) templ.Component {
diff --git a/internal/html/repo_log.templ b/internal/html/repo_log.templ
deleted file mode 100644
index f1517e54ce09efb84951a11a879a216aa022aa50..0000000000000000000000000000000000000000
--- a/internal/html/repo_log.templ
+++ /dev/null
@@ -1,36 +0,0 @@
-package html
-
-import "fmt"
-import "github.com/dustin/go-humanize"
-import "go.jolheiser.com/ugit/internal/git"
-
-type RepoLogContext struct {
- BaseContext
- RepoHeaderComponentContext
- Commits []git.Commit
-}
-
-templ RepoLog(rlc RepoLogContext) {
- @base(rlc.BaseContext) {
- @repoHeaderComponent(rlc.RepoHeaderComponentContext)
-
- for _, commit := range rlc.Commits {
-
-
{ commit.Short() }
-
- if commit.Details() != "" {
- { commit.Summary() }
{ commit.Details() }
- } else {
- { commit.Message }
- }
-
-
-
-
-
{ humanize.Time(commit.When) }
-
- }
-
- }
-}
-
diff --git a/internal/html/repo_log_templ.go b/internal/html/repo_log_templ.go
deleted file mode 100644
index d7478c29c1b30530e33eba2b25280d9c7c575a92..0000000000000000000000000000000000000000
--- a/internal/html/repo_log_templ.go
+++ /dev/null
@@ -1,198 +0,0 @@
-// Code generated by templ - DO NOT EDIT.
-
-// templ: version: v0.2.501
-package html
-
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
-
-import "github.com/a-h/templ"
-import "context"
-import "io"
-import "bytes"
-
-import "fmt"
-import "github.com/dustin/go-humanize"
-import "go.jolheiser.com/ugit/internal/git"
-
-type RepoLogContext struct {
- BaseContext
- RepoHeaderComponentContext
- Commits []git.Commit
-}
-
-func RepoLog(rlc RepoLogContext) templ.Component {
- return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
- templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
- if !templ_7745c5c3_IsBuffer {
- templ_7745c5c3_Buffer = templ.GetBuffer()
- defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
- }
- ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var1 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var1 == nil {
- templ_7745c5c3_Var1 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Var2 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
- templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
- if !templ_7745c5c3_IsBuffer {
- templ_7745c5c3_Buffer = templ.GetBuffer()
- defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
- }
- templ_7745c5c3_Err = repoHeaderComponent(rlc.RepoHeaderComponentContext).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- for _, commit := range rlc.Commits {
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var3 string
- templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(commit.Short())
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_log.templ`, Line: 18, Col: 26}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if commit.Details() != "" {
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var4 string
- templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(commit.Summary())
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_log.templ`, Line: 21, Col: 66}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var5 string
- templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(commit.Details())
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_log.templ`, Line: 21, Col: 96}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- } else {
- var templ_7745c5c3_Var6 string
- templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(commit.Message)
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_log.templ`, Line: 23, Col: 23}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var7 string
- templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(commit.Author)
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_log.templ`, Line: 28, Col: 25}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var8 string
- templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(" ")
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_log.templ`, Line: 28, Col: 32}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var10 string
- templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("<%s>", commit.Email))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_log.templ`, Line: 28, Col: 213}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- var templ_7745c5c3_Var11 string
- templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(humanize.Time(commit.When))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_log.templ`, Line: 29, Col: 93}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if !templ_7745c5c3_IsBuffer {
- _, templ_7745c5c3_Err = io.Copy(templ_7745c5c3_W, templ_7745c5c3_Buffer)
- }
- return templ_7745c5c3_Err
- })
- templ_7745c5c3_Err = base(rlc.BaseContext).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if !templ_7745c5c3_IsBuffer {
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
- }
- return templ_7745c5c3_Err
- })
-}
diff --git a/internal/html/repo_refs.templ b/internal/html/repo_refs.templ
index ad175328c78a639b72c9713ce056c231329f1aac..bb64ca1317907eab3455497b8954657565eb1dc0 100644
--- a/internal/html/repo_refs.templ
+++ b/internal/html/repo_refs.templ
@@ -18,7 +18,7 @@ Branches
for _, branch := range rrc.Branches {
{ branch }
-
+
}
}
@@ -27,13 +27,13 @@ Tags
for _, tag := range rrc.Tags {
{ tag.Name }
-
+
if tag.Signature != "" {
Signature
{ tag.Signature }
}
if tag.Annotation != "" {
import "fmt"
-
+ BaseContext
}
}
diff --git a/internal/html/repo_refs_templ.go b/internal/html/repo_refs_templ.go
index cc165204f57440938f8dc1d2bbaff4af9e683352..79da4eb93b3227d8528581203326b86b737a0940 100644
--- a/internal/html/repo_refs_templ.go
+++ b/internal/html/repo_refs_templ.go
@@ -110,7 +110,7 @@ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("