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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
{% extends "layout.html" %}
{% block title %}#{{ pull.number }} {{ pull.title }} — kitgit{% endblock %}
{% block content %}
<section class="kg-section">
<h1 class="kg-title">
<span class="kg-badge {% if pull.state == "open" %}kg-badge--open{% else %}kg-badge--closed{% endif %}">{{ pull.state }}</span>
#{{ pull.number }} {{ pull.title }}
</h1>
<p class="kg-meta">{{ pull.source_branch }} → {{ pull.target_branch }}</p>
<aside class="kg-issue-sidebar" style="margin:1rem 0">
<div class="kg-sidebar-block">
<h2 class="kg-kicker">labels</h2>
{% if labels.is_empty() %}<p class="kg-muted">None yet.</p>{% else %}<div class="kg-label-row">{% for l in labels %}<span class="kg-label-chip" style="background:{{ l.bg_color() }};color:{{ l.text_color() }}">{{ l.name }}</span>{% endfor %}</div>{% endif %}
{% if can_triage %}<form class="kg-form" method="post" action="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}/labels">{% for opt in label_options %}<label class="row"><input type="checkbox" name="label_id" value="{{ opt.label.id }}"{% if opt.selected %} checked{% endif %} /> <span class="kg-label-chip" style="background:{{ opt.label.bg_color() }};color:{{ opt.label.text_color() }}">{{ opt.label.name }}</span></label>{% endfor %}{% if !label_options.is_empty() %}<button class="kg-btn kg-btn--ghost" type="submit">save labels</button>{% endif %}</form>{% endif %}
</div>
<div class="kg-sidebar-block">
<h2 class="kg-kicker">milestone</h2>
{% if let Some(m) = milestone %}<p>{{ m.title }}</p>{% else %}<p class="kg-muted">No milestone</p>{% endif %}
{% if can_triage %}<form class="kg-form" method="post" action="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}/milestone"><label><select name="milestone_id"><option value="">none</option>{% for opt in milestone_options %}<option value="{{ opt.milestone.id }}"{% if opt.selected %} selected{% endif %}>{{ opt.milestone.title }}</option>{% endfor %}</select></label><button class="kg-btn kg-btn--ghost" type="submit">save milestone</button></form>{% endif %}
</div>
</aside>
{% let pr_tab = tab %}
{% let tab = "pulls" %}
{% let archive_ref = repo.default_branch %}
{% include "partials/repo_tabs.html" %}
<nav class="kg-pr-tabs" aria-label="Pull request">
<a href="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}?tab=conversation"{% if pr_tab == "conversation" %} aria-current="page"{% endif %}>
<span class="kg-icon" style="--icon:url('/static/icons/circle.svg')"></span>
conversation
<span class="kg-pr-tabs__count">{{ conversation_count }}</span>
</a>
<a href="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}?tab=commits"{% if pr_tab == "commits" %} aria-current="page"{% endif %}>
<span class="kg-icon" style="--icon:url('/static/icons/history.svg')"></span>
commits
<span class="kg-pr-tabs__count">{{ commits.len() }}</span>
</a>
<a href="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}?tab=files{% if show_full %}&full=1{% endif %}"{% if pr_tab == "files" %} aria-current="page"{% endif %}>
<span class="kg-icon" style="--icon:url('/static/icons/file.svg')"></span>
files
<span class="kg-pr-tabs__count">{{ diff_files.len() }}</span>
</a>
</nav>
{% if pr_tab == "conversation" %}
<article class="kg-comment">
<header>
<span>
<img class="kg-avatar kg-avatar--sm" src="{{ author_avatar }}" alt="" />
<a href="/{{ author.username }}">{{ author.username }}</a>
</span>
<span>{{ pull.created_at }}</span>
</header>
<div class="kg-readme">{{ body_html|safe }}</div>
</article>
{% for c in comments %}
<article class="kg-comment">
<header>
<span>
<img class="kg-avatar kg-avatar--sm" src="{{ c.avatar_url }}" alt="" />
<a href="/{{ c.author.username }}">{{ c.author.username }}</a>
</span>
<span>{{ c.created_at }}</span>
</header>
<div class="kg-readme">{{ c.body_html|safe }}</div>
{% include "partials/reactions.html" %}
</article>
{% endfor %}
{% for r in reviews %}
<article class="kg-comment kg-review">
<header>
<span>
<img class="kg-avatar kg-avatar--sm" src="{{ r.avatar_url }}" alt="" />
<a href="/{{ r.reviewer.username }}">{{ r.reviewer.username }}</a>
<span class="kg-badge {{ r.state_class() }}">{{ r.state_label() }}</span>
</span>
<span>{{ r.created_at }}</span>
</header>
{% if !r.body.is_empty() %}
<div class="kg-readme">{{ r.body_html|safe }}</div>
{% endif %}
</article>
{% endfor %}
{% if viewer.is_some() && pull.state == "open" %}
<form class="kg-form" method="post" action="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}/review">
<fieldset class="kg-review-state">
<legend>review</legend>
{% if !is_author %}
<label class="row">
<input type="radio" name="state" value="approved" />
approve
</label>
<label class="row">
<input type="radio" name="state" value="changes_requested" />
request changes
</label>
{% endif %}
<label class="row">
<input type="radio" name="state" value="commented" checked />
comment
</label>
</fieldset>
<label>
review notes
<textarea name="body" rows="4" placeholder="Leave a review comment (optional)"></textarea>
</label>
<div class="kg-actions">
<button class="kg-btn" type="submit">submit review</button>
</div>
</form>
{% endif %}
{% if viewer.is_some() %}
<form class="kg-form" method="post" action="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}">
<label>
comment
<textarea name="body" rows="4" required></textarea>
</label>
<div class="kg-actions">
<button class="kg-btn" type="submit">comment</button>
{% if pull.state == "open" %}
<button class="kg-btn kg-btn--ghost" formaction="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}/close" formmethod="post" type="submit" formnovalidate>close</button>
{% endif %}
</div>
</form>
{% endif %}
{% if can_merge && !merge_styles.is_empty() %}
<form class="kg-form" method="post" action="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}/merge">
<label>
merge style
<select name="style">
{% for style in merge_styles %}
<option value="{{ style }}"{% if style.as_str() == repo.default_merge_style.as_str() %} selected{% endif %}>{{ style }}</option>
{% endfor %}
</select>
</label>
<div class="kg-actions">
<button class="kg-btn" type="submit">merge</button>
</div>
</form>
{% endif %}
{% else if pr_tab == "commits" %}
{% if commits.is_empty() %}
<p class="kg-muted">No commits on this pull request.</p>
{% else %}
<ul class="kg-list">
{% for c in commits %}
<li>
<span>
<a href="/{{ owner.username }}/{{ repo.name }}/commits" title="View commits"><code>{{ c.short_id }}</code></a>
<a href="/{{ owner.username }}/{{ repo.name }}/commit/{{ c.id }}">{{ c.message }}</a>
{% let show_unverified = false %}
{% include "partials/verified_badge.html" %}
</span>
<span class="kg-meta">{{ c.author }}</span>
</li>
{% endfor %}
</ul>
{% endif %}
{% else %}
{% if diff_files.is_empty() %}
<p class="kg-muted">No file changes.</p>
{% else %}
<div class="kg-pr-files">
<aside class="kg-pr-files__nav" aria-label="Changed files">
<p class="kg-pr-files__nav-title">{{ diff_files.len() }} files</p>
<ul>
{% for f in diff_files %}
<li>
<a href="#{{ f.anchor }}">
<span class="kg-pr-files__path">{{ f.path }}</span>
<span class="kg-pr-files__stat">
{% if f.binary %}
binary
{% else %}
<span class="kg-pr-files__add">+{{ f.additions }}</span>
<span class="kg-pr-files__del">−{{ f.deletions }}</span>
{% endif %}
</span>
</a>
</li>
{% endfor %}
</ul>
</aside>
<div class="kg-pr-files__panels">
{% for f in diff_files %}
<section class="kg-diff-file" id="{{ f.anchor }}">
<header class="kg-diff-file__head">
<strong>{{ f.path }}</strong>
<span class="kg-meta">
{% if f.binary %}
binary
{% else %}
<span class="kg-pr-files__add">+{{ f.additions }}</span>
<span class="kg-pr-files__del">−{{ f.deletions }}</span>
{% endif %}
</span>
</header>
{{ f.html|safe }}
{% if f.truncated && !show_full %}
<p class="kg-diff__truncated">
Large diffs are not rendered by default.
Showing the first 50 of {{ f.total_lines }} lines.
<a class="kg-btn kg-btn--ghost" href="/{{ owner.username }}/{{ repo.name }}/pulls/{{ pull.number }}?tab=files&full=1#{{ f.anchor }}">Show full diff</a>
</p>
{% endif %}
</section>
{% endfor %}
</div>
</div>
{% endif %}
{% endif %}
</section>
{% endblock %}