~gitpocket/gitpocket

3
a6405613762b332d422d52f2973d2c576757190d
mainfeed-discovery
gitpocket/templates/pull.html -rw-r--r--6.9 KiB ViewLogBlameView rawPermalink a640561376 feat(basin): inline review comments on pull request diffs 1 months ago
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{{define "content"}}
{{$p := .Data.Page}}
{{$pr := .Data.Pull}}
<div class="pulltitle">
<h3 class="plain"><span class="state {{$pr.State}}">{{$pr.State}}</span> {{$pr.Title}} <span class="muted">#{{$pr.Number}}</span></h3>
<p class="muted"><a href="/~{{$pr.Author.Name}}">~{{$pr.Author.Name}}</a> wants to merge {{len .Data.Commits}} commits from <code>{{if $pr.SameRepo}}{{$pr.SourceBranch}}{{else}}{{$pr.SourceRepo.Path}}:{{$pr.SourceBranch}}{{end}}</code> into <code>{{$pr.TargetBranch}}</code> · opened {{ago $pr.Created}}{{if eq $pr.State "merged"}} · merged as <a href="/{{$p.Repo.Path}}/commit/{{$pr.Merged}}"><code>{{short $pr.Merged}}</code></a>{{end}}</p>
</div>
<div class="columns pullbody">
<div class="main">
{{if $pr.Body}}<div class="comment"><div class="who"><a href="/~{{$pr.Author.Name}}">~{{$pr.Author.Name}}</a> <span class="muted">{{ago $pr.Created}}</span></div><div class="readme">{{.Data.Body}}</div></div>{{end}}
{{range .Data.Comments}}<div class="comment"><div class="who"><a href="/~{{.Comment.Author.Name}}">~{{.Comment.Author.Name}}</a> <span class="muted">{{ago .Comment.Created}}</span></div><div class="readme">{{.Body}}</div></div>{{end}}
{{if .User}}<form method="post" action="/{{$p.Repo.Path}}/pulls/{{$pr.Number}}/comment" class="stack wide">
<label>Leave a comment <textarea name="body" rows="5" required placeholder="Markdown supported"></textarea></label>
<div class="actions"><button class="btn">Comment ▸</button></div>
</form>{{else}}<p class="muted"><a href="/login">Log in</a> to comment.</p>{{end}}
</div>
<aside>
<div class="panel">
{{if eq $pr.State "open"}}
{{if .Data.Unrelated}}<p>The branches have no common history.</p>
{{else if .Data.Mergeable}}<p>This branch can be merged automatically.</p>{{else}}<p>This branch has conflicts or nothing new to merge. Resolve locally, push, then update.</p>{{end}}
{{if .Data.Owner}}{{if .Data.Confirm}}
<form method="post" action="/{{$p.Repo.Path}}/pulls/{{$pr.Number}}/merge" class="stack mergeform">
<label>Commit message <input name="title" value="{{.Data.MergeTitle}}" maxlength="200" required></label>
<label>Extended description <textarea name="body" rows="4">{{$pr.Title}}</textarea></label>
<div class="actions left"><button class="btn primary">Confirm merge ▸</button><a class="btn" href="/{{$p.Repo.Path}}/pulls/{{$pr.Number}}">Cancel</a></div>
</form>
{{else}}{{if .Data.Mergeable}}<a class="btn primary block" href="?merge=1">Merge pull request ▸</a>{{else}}<button class="btn primary block" disabled>Merge pull request ▸</button>{{end}}{{end}}{{end}}
{{if or .Data.Owner .Data.Author}}<form method="post" action="/{{$p.Repo.Path}}/pulls/{{$pr.Number}}/update"><button class="btn block">Update from source ▸</button></form>
<form method="post" action="/{{$p.Repo.Path}}/pulls/{{$pr.Number}}/close"><button class="btn danger block">Close ▸</button></form>{{end}}
{{else if eq $pr.State "closed"}}<p>Closed without merging.</p>{{if or .Data.Owner .Data.Author}}<form method="post" action="/{{$p.Repo.Path}}/pulls/{{$pr.Number}}/reopen"><button class="btn block">Reopen ▸</button></form>{{end}}
{{else}}<p>Merged into <code>{{$pr.TargetBranch}}</code>.</p>{{end}}
<p class="muted small">Fetch locally with<br><code>git fetch https://{{.Host}}/{{$p.Repo.Path}} {{$pr.Ref}}</code></p>
</div>
</aside>
</div>
{{if .Data.Commits}}
<h3>Commits</h3>
<div class="log">{{range .Data.Commits}}<div class="event"><div><a class="hash" href="/{{$p.Repo.Path}}/commit/{{.Hash}}">{{short .Hash}}</a> <a class="subject" href="/{{$p.Repo.Path}}/commit/{{.Hash}}">{{.Subject}}</a>{{with signer .}}<span class="verified" title="Signed with a key registered by ~{{.}}">Verified ~{{.}}</span>{{end}}</div><div class="muted small">{{.Author}} · {{ago .Time}}</div></div>{{end}}</div>
{{end}}
{{if .Data.Files}}
<h3 id="diff">Changes <span class="muted">{{len .Data.Files}} files, <span class="add">+{{.Data.Added}}</span> <span class="del">−{{.Data.Removed}}</span>{{if .Data.ReviewCount}}, {{.Data.ReviewCount}} review comments{{end}}</span></h3>
{{if .User}}<p class="muted small">Click a line number to comment on that line.</p>{{end}}
{{range $file := .Data.Files}}
<section class="diff" id="{{.New}}">
<h4><a href="/{{$p.Repo.Path}}/tree/{{$.Data.Head}}/{{.New}}">{{if eq .Status "renamed"}}{{.Old}} → {{end}}{{.New}}</a> <span class="muted">{{.Status}}</span></h4>
{{if .Binary}}<p class="muted">Binary file.</p>{{end}}
{{range .Hunks}}
<table class="hunk">
<tr class="head"><td colspan="3">{{.Header}}</td></tr>
{{range .Lines}}{{$side := "n"}}{{$num := .New}}{{if eq .Kind "del"}}{{$side = "o"}}{{$num = .Old}}{{end}}{{$key := printf "%s:%s:%d" $file.New $side $num}}
<tr class="{{.Kind}}" id="r-{{$key}}"><td class="n">{{if .Old}}{{if and $.User (ne .Kind "meta")}}<a href="?comment={{$file.New}}:o:{{.Old}}#r-{{$file.New}}:o:{{.Old}}">{{.Old}}</a>{{else}}{{.Old}}{{end}}{{end}}</td><td class="n">{{if .New}}{{if and $.User (ne .Kind "meta")}}<a href="?comment={{$file.New}}:n:{{.New}}#r-{{$file.New}}:n:{{.New}}">{{.New}}</a>{{else}}{{.New}}{{end}}{{end}}</td><td class="l">{{if eq .Kind "add"}}+{{else if eq .Kind "del"}}-{{else if eq .Kind "ctx"}} {{end}}{{.Text}}</td></tr>
{{template "reviews" (index $.Data.Inline $key)}}
{{if eq $.Data.CommentAt $key}}<tr class="inline"><td colspan="3"><form method="post" action="/{{$p.Repo.Path}}/pulls/{{$pr.Number}}/review" class="stack wide reviewform"><input type="hidden" name="path" value="{{$file.New}}"><input type="hidden" name="side" value="{{$side}}"><input type="hidden" name="line" value="{{$num}}"><textarea name="body" rows="4" required autofocus placeholder="Markdown supported"></textarea><div class="actions left"><button class="btn primary">Comment ▸</button><a class="btn" href="/{{$p.Repo.Path}}/pulls/{{$pr.Number}}#diff">Cancel</a></div></form></td></tr>{{end}}
{{end}}
</table>
{{end}}
</section>
{{end}}
{{with .Data.Outdated}}
<h4>Outdated review comments</h4>
<p class="muted small">These lines are no longer in the diff.</p>
{{range .}}<div class="comment outdated"><div class="who"><a href="/~{{.Author.Name}}">~{{.Author.Name}}</a> <span class="muted">on {{.Path}} line {{.Line}} · {{ago .Created}}</span></div><div class="readme">{{.HTML}}</div></div>{{end}}
{{end}}
{{end}}
{{end}}
{{define "reviews"}}{{range .}}<tr class="inline{{if .Resolved}} resolved{{end}}"><td colspan="3"><div class="comment"><div class="who"><a href="/~{{.Author.Name}}">~{{.Author.Name}}</a> <span class="muted">{{ago .Created}}{{if .Resolved}} · resolved{{end}}</span>{{if .CanEdit}}<span class="tools"><form method="post" action="{{.URL}}/{{if .Resolved}}unresolve{{else}}resolve{{end}}"><input type="hidden" name="review" value="{{.ID}}"><button>{{if .Resolved}}Unresolve{{else}}Resolve{{end}}</button></form><form method="post" action="{{.URL}}/delete"><input type="hidden" name="review" value="{{.ID}}"><button>Delete</button></form></span>{{end}}</div>{{if not .Resolved}}<div class="readme">{{.HTML}}</div>{{end}}</div></td></tr>{{end}}{{end}}