aboutsummaryrefslogtreecommitdiffstats
path: root/templates/repo/issue/view_content/pull.tmpl
blob: c7cf737b34917a9744377b72859ae5836ddab06c (plain)
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
{{if gt (len .PullReviewers) 0}}
	<div class="comment box">
		<div class="content">
			<div class="ui segment">
				<h4>{{$.i18n.Tr "repo.issues.review.reviewers"}}</h4>
				{{range .PullReviewers}}
					{{ $createdStr:= TimeSinceUnix .UpdatedUnix $.Lang }}
					<div class="ui divider"></div>
					<div class="review-item">
						<span class="type-icon text {{if eq .Type 1}}green
							{{- else if eq .Type 2}}grey
							{{- else if eq .Type 3}}red
							{{- else}}grey{{end}}">
							{{svg (printf "octicon-%s" .Type.Icon) 16}}
						</span>
						{{if .Stale}}
						<span class="type-icon text grey">
							<i class="octicon icon fa-hourglass-end"></i>
						</span>
						{{end}}
						<a class="ui avatar image" href="{{.Reviewer.HomeLink}}">
							<img src="{{.Reviewer.RelAvatarLink}}">
						</a>
						<span class="text grey"><a href="{{.Reviewer.HomeLink}}">{{.Reviewer.Name}}</a>
							{{if eq .Type 1}}
								{{$.i18n.Tr "repo.issues.review.approve" $createdStr | Safe}}
							{{else if eq .Type 2}}
								{{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
							{{else if eq .Type 3}}
								{{$.i18n.Tr "repo.issues.review.reject" $createdStr | Safe}}
							{{else}}
								{{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
							{{end}}
						</span>
					</div>
				{{end}}
			</div>
		</div>
	</div>
{{end}}
<div class="comment merge box">
	<a class="avatar text  {{if .Issue.PullRequest.HasMerged}}purple
	{{- else if .Issue.IsClosed}}grey
	{{- else if .IsPullWorkInProgress}}grey
	{{- else if .IsFilesConflicted}}grey
	{{- else if .IsPullRequestBroken}}red
	{{- else if .IsBlockedByApprovals}}red
	{{- else if .IsBlockedByRejection}}red
	{{- else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsFailure .RequiredStatusCheckState.IsError)}}red
	{{- else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsPending .RequiredStatusCheckState.IsWarning)}}yellow
	{{- else if and .RequireSigned (not .WillSign)}}}red
	{{- else if .Issue.PullRequest.IsChecking}}yellow
	{{- else if .Issue.PullRequest.CanAutoMerge}}green
	{{- else}}red{{end}}">{{svg "octicon-git-merge" 32}}</a>
	<div class="content">
		{{template "repo/pulls/status" .}}
		<div class="ui {{if not $.LatestCommitStatus}}top attached header{{else}}attached merge-section segment{{end}}">
			{{if .Issue.PullRequest.HasMerged}}
				<div class="item text purple">
					{{if .Issue.PullRequest.MergedCommitID}}
						{{$link := printf "%s/commit/%s" $.Repository.HTMLURL .Issue.PullRequest.MergedCommitID}}
						{{$.i18n.Tr "repo.pulls.merged_as" $link (ShortSha .Issue.PullRequest.MergedCommitID) | Safe}}
					{{else}}
						{{$.i18n.Tr "repo.pulls.has_merged"}}
					{{end}}
				</div>
				{{if .IsPullBranchDeletable}}
					<div class="ui divider"></div>
					<div>
						<a class="delete-button ui red button" href="" data-url="{{.DeleteBranchLink}}">{{$.i18n.Tr "repo.branch.delete" .HeadTarget}}</a>
					</div>
				{{end}}
			{{else if .Issue.IsClosed}}
				<div class="item text grey">
					{{if .IsPullRequestBroken}}
						{{$.i18n.Tr "repo.pulls.cant_reopen_deleted_branch"}}
					{{else}}
						{{$.i18n.Tr "repo.pulls.reopen_to_merge"}}
					{{end}}
				</div>
				{{if and .IsPullBranchDeletable ( not .IsPullRequestBroken )}}
					<div class="ui divider"></div>
					<div>
						<a class="delete-button ui red button" href="" data-url="{{.DeleteBranchLink}}">{{$.i18n.Tr "repo.branch.delete" .HeadTarget}}</a>
					</div>
				{{end}}
			{{else if .IsPullFilesConflicted}}
				<div class="item text grey">
					{{svg "octicon-x" 16}}
					{{$.i18n.Tr "repo.pulls.files_conflicted"}}
					{{range .ConflictedFiles}}
						<div>{{.}}</div>
					{{end}}
				</div>
			{{else if .IsPullRequestBroken}}
				<div class="item text red">
					<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
					{{$.i18n.Tr "repo.pulls.data_broken"}}
				</div>
			{{else if .IsPullWorkInProgress}}
				<div class="item text grey">
					<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
					{{$.i18n.Tr "repo.pulls.cannot_merge_work_in_progress" .WorkInProgressPrefix | Str2html}}
				</div>
			{{else if .Issue.PullRequest.IsChecking}}
				<div class="item text yellow">
					<i class="icon icon-octicon">{{svg "octicon-sync" 16}}</i>
					{{$.i18n.Tr "repo.pulls.is_checking"}}
				</div>
			{{else if .Issue.PullRequest.CanAutoMerge}}
				{{if .IsBlockedByApprovals}}
					<div class="item text red">
						<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
					{{$.i18n.Tr "repo.pulls.blocked_by_approvals" .GrantedApprovals .Issue.PullRequest.ProtectedBranch.RequiredApprovals}}
					</div>
				{{else if .IsBlockedByRejection}}
					<div class="item text red">
						<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
					{{$.i18n.Tr "repo.pulls.blocked_by_rejection"}}
					</div>
				{{else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsError .RequiredStatusCheckState.IsFailure)}}
					<div class="item text red">
						<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
						{{$.i18n.Tr "repo.pulls.required_status_check_failed"}}
					</div>
				{{else if and .RequireSigned (not .WillSign)}}
					<div class="item text red">
						<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
						{{$.i18n.Tr "repo.pulls.require_signed_wont_sign"}}
					</div>
					<div class="item text yellow">
						<i class="icon unlock"></i>
						{{$.i18n.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason) }}
					</div>
				{{end}}
				{{$notAllOverridableChecksOk := or .IsBlockedByApprovals .IsBlockedByRejection (and .EnableStatusCheck (not .IsRequiredStatusCheckSuccess))}}
				{{if and (or $.IsRepoAdmin (not $notAllOverridableChecksOk)) (or (not .RequireSigned) .WillSign)}}
					{{if $notAllOverridableChecksOk}}
						<div class="item text yellow">
							<i class="icon icon-octicon">{{svg "octicon-primitive-dot" 16}}</i>
							{{$.i18n.Tr "repo.pulls.required_status_check_administrator"}}
						</div>
					{{else}}
						<div class="item text green">
							<i class="icon icon-octicon">{{svg "octicon-check" 16}}</i>
							{{$.i18n.Tr "repo.pulls.can_auto_merge_desc"}}
						</div>
					{{end}}
					{{if .WillSign}}
						<div class="item text green">
							<i class="icon lock green"></i>
							{{$.i18n.Tr "repo.signing.will_sign" .SigningKey}}
						</div>
					{{else if .IsSigned}}
						<div class="item text">
							<i class="icon unlock"></i>
							{{$.i18n.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason) }}
						</div>
					{{end}}
					{{if .AllowMerge}}
						{{$prUnit := .Repository.MustGetUnit $.UnitTypePullRequests}}
						{{$approvers := .Issue.PullRequest.GetApprovers}}
						{{if or $prUnit.PullRequestsConfig.AllowMerge $prUnit.PullRequestsConfig.AllowRebase $prUnit.PullRequestsConfig.AllowRebaseMerge $prUnit.PullRequestsConfig.AllowSquash}}
							<div class="ui divider"></div>
							{{if $prUnit.PullRequestsConfig.AllowMerge}}
							<div class="ui form merge-fields" style="display: none">
								<form action="{{.Link}}/merge" method="post">
									{{.CsrfTokenHtml}}
									<div class="field">
										<input type="text" name="merge_title_field" value="{{.Issue.PullRequest.GetDefaultMergeMessage}}">
									</div>
									<div class="field">
										<textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}">Reviewed-on: {{$.Issue.HTMLURL}}&#13;&#10;{{$approvers}}</textarea>
									</div>
									<button class="ui green button" type="submit" name="do" value="merge">
										{{$.i18n.Tr "repo.pulls.merge_pull_request"}}
									</button>
									<button class="ui button merge-cancel">
										{{$.i18n.Tr "cancel"}}
									</button>
								</form>
							</div>
							{{end}}
							{{if $prUnit.PullRequestsConfig.AllowRebase}}
							<div class="ui form rebase-fields" style="display: none">
								<form action="{{.Link}}/merge" method="post">
									{{.CsrfTokenHtml}}
									<button class="ui green button" type="submit" name="do" value="rebase">
										{{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}
									</button>
									<button class="ui button merge-cancel">
										{{$.i18n.Tr "cancel"}}
									</button>
								</form>
							</div>
							{{end}}
							{{if $prUnit.PullRequestsConfig.AllowRebaseMerge}}
							<div class="ui form rebase-merge-fields" style="display: none">
								<form action="{{.Link}}/merge" method="post">
									{{.CsrfTokenHtml}}
									<div class="field">
										<input type="text" name="merge_title_field" value="{{.Issue.PullRequest.GetDefaultMergeMessage}}">
									</div>
									<div class="field">
										<textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}">Reviewed-on: {{$.Issue.HTMLURL}}&#13;&#10;{{$approvers}}</textarea>
									</div>
									<button class="ui green button" type="submit" name="do" value="rebase-merge">
										{{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}
									</button>
									<button class="ui button merge-cancel">
										{{$.i18n.Tr "cancel"}}
									</button>
								</form>
							</div>
							{{end}}
							{{if $prUnit.PullRequestsConfig.AllowSquash}}
							{{$commitMessages := .Issue.PullRequest.GetCommitMessages}}
							<div class="ui form squash-fields" style="display: none">
								<form action="{{.Link}}/merge" method="post">
									{{.CsrfTokenHtml}}
									<div class="field">
										<input type="text" name="merge_title_field" value="{{.Issue.PullRequest.GetDefaultSquashMessage}}">
									</div>
									<div class="field">
										<textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}">{{$commitMessages}}Reviewed-on: {{$.Issue.HTMLURL}}&#13;&#10;{{$approvers}}</textarea>
									</div>
									<button class="ui green button" type="submit" name="do" value="squash">
										{{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}
									</button>
									<button class="ui button merge-cancel">
										{{$.i18n.Tr "cancel"}}
									</button>
								</form>
							</div>
							{{end}}
							<div class="ui {{if $notAllOverridableChecksOk}}red{{else}}green{{end}} buttons merge-button">
								<button class="ui button" data-do="{{.MergeStyle}}">
									{{svg "octicon-git-merge" 16}}
									<span class="button-text">
									{{if eq .MergeStyle "merge"}}
										{{$.i18n.Tr "repo.pulls.merge_pull_request"}}
									{{end}}
									{{if eq .MergeStyle "rebase"}}
										{{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}
									{{end}}
									{{if eq .MergeStyle "rebase-merge"}}
										{{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}
									{{end}}
									{{if eq .MergeStyle "squash"}}
										{{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}
									{{end}}
									</span>
								</button>
								<div class="ui dropdown icon button">
									<i class="dropdown icon"></i>
									<div class="menu">
										{{if $prUnit.PullRequestsConfig.AllowMerge}}
										<div class="item{{if eq .MergeStyle "merge"}} active selected{{end}}" data-do="merge">{{$.i18n.Tr "repo.pulls.merge_pull_request"}}</div>
										{{end}}
										{{if $prUnit.PullRequestsConfig.AllowRebase}}
										<div class="item{{if eq .MergeStyle "rebase"}} active selected{{end}}" data-do="rebase">{{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}</div>
										{{end}}
										{{if $prUnit.PullRequestsConfig.AllowRebaseMerge}}
										<div class="item{{if eq .MergeStyle "rebase-merge"}} active selected{{end}}" data-do="rebase-merge">{{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}</div>
										{{end}}
										{{if $prUnit.PullRequestsConfig.AllowSquash}}
										<div class="item{{if eq .MergeStyle "squash"}} active selected{{end}}" data-do="squash">{{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}</div>
										{{end}}
									</div>
								</div>
							</div>
						{{else}}
							<div class="item text red">
								{{svg "octicon-x" 16}}
								{{$.i18n.Tr "repo.pulls.no_merge_desc"}}
							</div>
							<div class="item text grey">
								{{svg "octicon-info" 16}}
								{{$.i18n.Tr "repo.pulls.no_merge_helper"}}
							</div>
						{{end}}
					{{else}}
						<div class="item text grey">
							{{svg "octicon-info" 16}}
							{{$.i18n.Tr "repo.pulls.no_merge_access"}}
						</div>
					{{end}}
				{{end}}
				{{if and .Divergence (gt .Divergence.Behind 0)}}
				<div class="ui very compact branch-update grid">
						<div class="row">
						<div class="item text gray eleven wide left floated column">
							<i class="icon icon-octicon">{{svg "octicon-alert" 16}}</i>
							{{$.i18n.Tr "repo.pulls.outdated_with_base_branch"}}
						</div>
						{{if .UpdateAllowed}}
							<div class="item text five wide right floated column">
								<form action="{{.Link}}/update" method="post">
									{{.CsrfTokenHtml}}
									<button class="ui button" data-do="update">
										<span class="item text">{{$.i18n.Tr "repo.pulls.update_branch"}}</span>
									</button>
								</form>
							</div>
						{{end}}
					</div>
				</div>
				{{end}}
			{{else}}
				{{/* Merge conflict without specific file. Suggest manual merge, only if all reviews and status checks OK. */}}
				{{if .IsBlockedByApprovals}}
					<div class="item text red">
						{{svg "octicon-x" 16}}
					{{$.i18n.Tr "repo.pulls.blocked_by_approvals" .GrantedApprovals .Issue.PullRequest.ProtectedBranch.RequiredApprovals}}
					</div>
				{{else if .IsBlockedByRejection}}
					<div class="item text red">
						{{svg "octicon-x" 16}}
					{{$.i18n.Tr "repo.pulls.blocked_by_rejection"}}
					</div>
				{{else if and .EnableStatusCheck (not .IsRequiredStatusCheckSuccess)}}
					<div class="item text red">
						{{svg "octicon-x" 16}}
						{{$.i18n.Tr "repo.pulls.required_status_check_failed"}}
					</div>
				{{else if and .RequireSigned (not .WillSign)}}
					<div class="item text red">
						{{svg "octicon-x" 16}}
						{{$.i18n.Tr "repo.pulls.require_signed_wont_sign"}}
					</div>
				{{else}}
					<div class="item text red">
						{{svg "octicon-x" 16}}
						{{$.i18n.Tr "repo.pulls.cannot_auto_merge_desc"}}
					</div>
					<div class="item text grey">
						{{svg "octicon-info" 16}}
						{{$.i18n.Tr "repo.pulls.cannot_auto_merge_helper"}}
					</div>
				{{end}}
			{{end}}
		</div>
	</div>
</div>