Mirror of https://git.jolheiser.com/ugit
1package html
2
3import "fmt"
4import "github.com/dustin/go-humanize"
5import "go.jolheiser.com/ugit/internal/git"
6
7type RepoCommitContext struct{
8 BaseContext
9 RepoHeaderComponentContext
10 Commit git.Commit
11}
12
13templ RepoCommit(rcc RepoCommitContext) {
14 @base(rcc.BaseContext) {
15 @repoHeaderComponent(rcc.RepoHeaderComponentContext)
16 <div class="text-text mt-5"><a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("/%s/tree/%s/", rcc.RepoHeaderComponentContext.Name, rcc.Commit.SHA)) }>tree</a>{ " " }<a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("/%s/log/%s", rcc.RepoHeaderComponentContext.Name, rcc.Commit.SHA)) }>log</a>{ " " }<a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("/%s/commit/%s.patch", rcc.RepoHeaderComponentContext.Name, rcc.Commit.SHA)) }>patch</a></div>
17 <div class="text-text whitespace-pre mt-5 p-3 bg-base rounded">{ rcc.Commit.Message }</div>
18 if rcc.Commit.Signature != "" {
19 <details class="text-text whitespace-pre">
20 <summary class="cursor-pointer">Signature</summary>
21 <div class="p-3 bg-base rounded"><code>{ rcc.Commit.Signature }</code></div>
22 </details>
23 }
24 <div class="text-text mt-3">
25 <div>{ rcc.Commit.Author }{ " " }<a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("mailto:%s", rcc.Commit.Email)) }>{ fmt.Sprintf("<%s>", rcc.Commit.Email) }</a></div>
26 <div title={ rcc.Commit.When.Format("01/02/2006 03:04:05 PM") }>{ humanize.Time(rcc.Commit.When) }</div>
27 </div>
28 <div class="text-text mt-5">{ fmt.Sprintf("%d changed files, %d additions(+), %d deletions(-)", rcc.Commit.Stats.Changed, rcc.Commit.Stats.Additions, rcc.Commit.Stats.Deletions) }</div>
29 for _, file := range rcc.Commit.Files {
30 <div class="text-text mt-5">
31 <span class="text-text/80" title={ file.Action }>{ string(file.Action[0]) }</span>
32 { " " }
33 if file.From.Path != "" {
34 <a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("/%s/tree/%s/%s", rcc.RepoHeaderComponentContext.Name, file.From.Commit, file.From.Path)) }>{ file.From.Path }</a>
35 }
36 if file.From.Path != "" && file.To.Path != "" {
37 { " -> " }
38 }
39 if file.To.Path != "" {
40 <a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("/%s/tree/%s/%s", rcc.RepoHeaderComponentContext.Name, file.To.Commit, file.To.Path)) }>{ file.To.Path }</a>
41 }
42 </div>
43 <div class="whitespace-pre code">@templ.Raw(file.Patch)</div>
44 }
45 }
46}
47