2022-08-31 23:58:54 +08:00
|
|
|
{{if or .PullReviewers .OriginalReviews}}
|
2018-11-22 21:17:36 +08:00
|
|
|
<div class="comment box">
|
|
|
|
<div class="content">
|
|
|
|
<div class="ui segment">
|
2022-06-28 04:58:46 +08:00
|
|
|
<h4>{{$.locale.Tr "repo.issues.review.reviewers"}}</h4>
|
2019-12-04 09:08:56 +08:00
|
|
|
{{range .PullReviewers}}
|
2022-08-31 23:58:54 +08:00
|
|
|
{{$createdStr:= TimeSinceUnix .Review.UpdatedUnix $.locale}}
|
2018-11-22 21:17:36 +08:00
|
|
|
<div class="ui divider"></div>
|
|
|
|
<div class="review-item">
|
2020-06-15 15:37:00 +08:00
|
|
|
<div class="review-item-left">
|
2020-10-13 03:55:13 +08:00
|
|
|
{{if .User}}
|
2020-12-04 02:46:11 +08:00
|
|
|
<a href="{{.User.HomeLink}}">
|
Add context cache as a request level cache (#22294)
To avoid duplicated load of the same data in an HTTP request, we can set
a context cache to do that. i.e. Some pages may load a user from a
database with the same id in different areas on the same page. But the
code is hidden in two different deep logic. How should we share the
user? As a result of this PR, now if both entry functions accept
`context.Context` as the first parameter and we just need to refactor
`GetUserByID` to reuse the user from the context cache. Then it will not
be loaded twice on an HTTP request.
But of course, sometimes we would like to reload an object from the
database, that's why `RemoveContextData` is also exposed.
The core context cache is here. It defines a new context
```go
type cacheContext struct {
ctx context.Context
data map[any]map[any]any
lock sync.RWMutex
}
var cacheContextKey = struct{}{}
func WithCacheContext(ctx context.Context) context.Context {
return context.WithValue(ctx, cacheContextKey, &cacheContext{
ctx: ctx,
data: make(map[any]map[any]any),
})
}
```
Then you can use the below 4 methods to read/write/del the data within
the same context.
```go
func GetContextData(ctx context.Context, tp, key any) any
func SetContextData(ctx context.Context, tp, key, value any)
func RemoveContextData(ctx context.Context, tp, key any)
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error)
```
Then let's take a look at how `system.GetString` implement it.
```go
func GetSetting(ctx context.Context, key string) (string, error) {
return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
return cache.GetString(genSettingCacheKey(key), func() (string, error) {
res, err := GetSettingNoCache(ctx, key)
if err != nil {
return "", err
}
return res.SettingValue, nil
})
})
}
```
First, it will check if context data include the setting object with the
key. If not, it will query from the global cache which may be memory or
a Redis cache. If not, it will get the object from the database. In the
end, if the object gets from the global cache or database, it will be
set into the context cache.
An object stored in the context cache will only be destroyed after the
context disappeared.
2023-02-15 21:37:34 +08:00
|
|
|
{{avatar $.Context .User}}
|
2020-10-13 03:55:13 +08:00
|
|
|
</a>
|
|
|
|
{{end}}
|
2021-05-28 04:02:04 +08:00
|
|
|
<span>
|
2020-10-13 03:55:13 +08:00
|
|
|
{{if .User}}
|
2020-11-04 17:11:19 +08:00
|
|
|
<a href="{{.User.HomeLink}}">{{.User.GetDisplayName}}</a>
|
2020-10-13 03:55:13 +08:00
|
|
|
{{else if .Team}}
|
|
|
|
<span class="ui text">{{$.Issue.Repo.OwnerName}}/{{.Team.Name}}</span>
|
|
|
|
{{end}}
|
|
|
|
{{if eq .Review.Type 1}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.issues.review.approve" $createdStr | Safe}}
|
2020-10-13 03:55:13 +08:00
|
|
|
{{else if eq .Review.Type 2}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.issues.review.comment" $createdStr | Safe}}
|
2020-10-13 03:55:13 +08:00
|
|
|
{{else if eq .Review.Type 3}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.issues.review.reject" $createdStr | Safe}}
|
2020-10-13 03:55:13 +08:00
|
|
|
{{else if eq .Review.Type 4}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.issues.review.wait" $createdStr | Safe}}
|
2020-06-15 15:37:00 +08:00
|
|
|
{{else}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.issues.review.comment" $createdStr | Safe}}
|
2020-04-07 00:33:34 +08:00
|
|
|
{{end}}
|
2020-06-15 15:37:00 +08:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div class="review-item-right">
|
2020-10-13 03:55:13 +08:00
|
|
|
{{if .Review.Stale}}
|
2022-06-28 04:58:46 +08:00
|
|
|
<span class="ui tooltip type-icon text grey" data-content="{{$.locale.Tr "repo.issues.is_stale"}}">
|
2021-05-23 05:29:46 +08:00
|
|
|
{{svg "octicon-hourglass" 16 "icon"}}
|
2021-02-12 01:32:25 +08:00
|
|
|
</span>
|
|
|
|
{{end}}
|
|
|
|
{{if (and $.Permission.IsAdmin (or (eq .Review.Type 1) (eq .Review.Type 3)) (not $.Issue.IsClosed))}}
|
2022-06-28 04:58:46 +08:00
|
|
|
<a href="#" class="ui muted tooltip icon dismiss-review-btn" data-review-id="dismiss-review-{{.Review.ID}}" data-content="{{$.locale.Tr "repo.issues.dismiss_review"}}">
|
2021-02-12 01:32:25 +08:00
|
|
|
{{svg "octicon-x" 16}}
|
|
|
|
</a>
|
|
|
|
<div class="ui small modal" id="dismiss-review-modal">
|
|
|
|
<div class="header">
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.issues.dismiss_review"}}
|
2021-02-12 01:32:25 +08:00
|
|
|
</div>
|
|
|
|
<div class="content">
|
|
|
|
<div class="ui warning message text left">
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.issues.dismiss_review_warning"}}
|
2021-02-12 01:32:25 +08:00
|
|
|
</div>
|
|
|
|
<form class="ui form dismiss-review-form" id="dismiss-review-{{.Review.ID}}" action="{{$.RepoLink}}/issues/dismiss_review" method="post">
|
|
|
|
{{$.CsrfTokenHtml}}
|
|
|
|
<input type="hidden" name="review_id" value="{{.Review.ID}}">
|
|
|
|
<div class="field">
|
2022-06-28 04:58:46 +08:00
|
|
|
<label for="message">{{$.locale.Tr "action.review_dismissed_reason"}}</label>
|
2021-02-12 01:32:25 +08:00
|
|
|
<input id="message" name="message">
|
|
|
|
</div>
|
|
|
|
<div class="text right actions">
|
2022-06-28 04:58:46 +08:00
|
|
|
<div class="ui cancel button">{{$.locale.Tr "settings.cancel"}}</div>
|
|
|
|
<button class="ui red button" type="submit">{{$.locale.Tr "ok"}}</button>
|
2021-02-12 01:32:25 +08:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-04-07 00:33:34 +08:00
|
|
|
{{end}}
|
2020-10-13 03:55:13 +08:00
|
|
|
<span class="type-icon text {{if eq .Review.Type 1}}green
|
|
|
|
{{- else if eq .Review.Type 2}}grey
|
|
|
|
{{- else if eq .Review.Type 3}}red
|
|
|
|
{{- else if eq .Review.Type 4}}yellow
|
2020-06-15 15:37:00 +08:00
|
|
|
{{else}}grey{{end}}">
|
2020-04-07 00:33:34 +08:00
|
|
|
|
2022-08-31 23:58:54 +08:00
|
|
|
{{if .CanChange}}
|
2022-06-28 04:58:46 +08:00
|
|
|
<a href="#" class="ui tooltip icon re-request-review {{if .Checked}}checked{{end}}" data-issue-id="{{$.Issue.ID}}" data-content="{{if .Checked}} {{$.locale.Tr "repo.issues.remove_request_review"}} {{else}} {{$.locale.Tr "repo.issues.re_request_review"}} {{end}}" data-id="{{.ItemID}}" data-update-url="{{$.RepoLink}}/issues/request_review">
|
2021-03-22 12:04:19 +08:00
|
|
|
{{if .Checked}} {{svg "octicon-trash"}} {{else}} {{svg "octicon-sync"}} {{end}}
|
2020-06-15 15:37:00 +08:00
|
|
|
</a>
|
|
|
|
{{end}}
|
2020-10-13 03:55:13 +08:00
|
|
|
{{svg (printf "octicon-%s" .Review.Type.Icon)}}
|
2020-06-15 15:37:00 +08:00
|
|
|
</span>
|
|
|
|
</div>
|
2018-11-22 21:17:36 +08:00
|
|
|
</div>
|
|
|
|
{{end}}
|
2020-10-14 20:11:11 +08:00
|
|
|
{{range .OriginalReviews}}
|
2022-08-31 23:58:54 +08:00
|
|
|
{{$createdStr:= TimeSinceUnix .UpdatedUnix $.locale}}
|
2020-10-14 20:11:11 +08:00
|
|
|
<div class="ui divider"></div>
|
|
|
|
<div class="review-item">
|
|
|
|
<div class="review-item-left">
|
2022-08-31 23:58:54 +08:00
|
|
|
<a href="{{$.Repository.OriginalURL}}" class="ui tooltip" data-content="{{$.locale.Tr "repo.migrated_from_fake" ($.Repository.GetOriginalURLHostname|Escape) | Safe}}">
|
2021-09-19 00:22:51 +08:00
|
|
|
<span class="text black ">
|
|
|
|
{{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}}
|
2022-08-31 23:58:54 +08:00
|
|
|
{{.OriginalAuthor}}
|
2021-09-19 00:22:51 +08:00
|
|
|
</span>
|
|
|
|
</a>
|
2020-10-14 20:11:11 +08:00
|
|
|
</div>
|
|
|
|
<div class="review-item-right">
|
|
|
|
<span class="type-icon text {{if eq .Type 1}}green
|
|
|
|
{{- else if eq .Type 2}}grey
|
|
|
|
{{- else if eq .Type 3}}red
|
|
|
|
{{- else if eq .Type 4}}yellow
|
|
|
|
{{else}}grey{{end}}">
|
|
|
|
{{svg (printf "octicon-%s" .Type.Icon)}}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
2018-11-22 21:17:36 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
2020-04-11 06:01:41 +08:00
|
|
|
<div class="timeline-item comment merge box">
|
|
|
|
<a class="timeline-avatar text {{if .Issue.PullRequest.HasMerged}}purple
|
2020-04-03 13:12:42 +08:00
|
|
|
{{- 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
|
2020-11-29 03:30:46 +08:00
|
|
|
{{- else if .IsBlockedByOfficialReviewRequests}}red
|
2020-04-17 09:00:36 +08:00
|
|
|
{{- else if .IsBlockedByOutdatedBranch}}red
|
2020-10-14 02:50:57 +08:00
|
|
|
{{- else if .IsBlockedByChangedProtectedFiles}}red
|
2020-04-03 13:12:42 +08:00
|
|
|
{{- else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsFailure .RequiredStatusCheckState.IsError)}}red
|
2020-04-16 04:35:18 +08:00
|
|
|
{{- else if and .EnableStatusCheck (or (not $.LatestCommitStatus) .RequiredStatusCheckState.IsPending .RequiredStatusCheckState.IsWarning)}}yellow
|
2020-08-24 05:59:41 +08:00
|
|
|
{{- else if and .AllowMerge .RequireSigned (not .WillSign)}}red
|
2020-04-03 13:12:42 +08:00
|
|
|
{{- else if .Issue.PullRequest.IsChecking}}yellow
|
2021-03-04 11:41:23 +08:00
|
|
|
{{- else if .Issue.PullRequest.IsEmpty}}grey
|
2020-04-03 13:12:42 +08:00
|
|
|
{{- else if .Issue.PullRequest.CanAutoMerge}}green
|
|
|
|
{{- else}}red{{end}}">{{svg "octicon-git-merge" 32}}</a>
|
2017-03-17 13:57:43 +08:00
|
|
|
<div class="content">
|
2019-06-30 15:57:59 +08:00
|
|
|
{{template "repo/pulls/status" .}}
|
2020-06-14 02:49:59 +08:00
|
|
|
{{$canAutoMerge := false}}
|
2020-05-26 03:08:06 +08:00
|
|
|
<div class="ui attached merge-section segment {{if not $.LatestCommitStatus}}no-header{{end}}">
|
2017-03-17 13:57:43 +08:00
|
|
|
{{if .Issue.PullRequest.HasMerged}}
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item text">
|
2019-09-03 14:29:36 +08:00
|
|
|
{{if .Issue.PullRequest.MergedCommitID}}
|
2023-02-07 02:09:18 +08:00
|
|
|
{{$link := printf "%s/commit/%s" $.Repository.Link (.Issue.PullRequest.MergedCommitID|PathEscape)}}
|
2021-03-04 11:41:23 +08:00
|
|
|
{{if eq $.Issue.PullRequest.Status 3}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.manually_merged_as" ($link|Escape) (ShortSha .Issue.PullRequest.MergedCommitID) | Safe}}
|
2021-03-04 11:41:23 +08:00
|
|
|
{{else}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.merged_as" ($link|Escape) (ShortSha .Issue.PullRequest.MergedCommitID) | Safe}}
|
2021-03-04 11:41:23 +08:00
|
|
|
{{end}}
|
2019-09-03 14:29:36 +08:00
|
|
|
{{else}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.has_merged"}}
|
2019-09-03 14:29:36 +08:00
|
|
|
{{end}}
|
2017-03-17 13:57:43 +08:00
|
|
|
</div>
|
|
|
|
{{if .IsPullBranchDeletable}}
|
|
|
|
<div class="ui divider"></div>
|
|
|
|
<div>
|
2022-06-28 04:58:46 +08:00
|
|
|
<a class="delete-button ui red button" href="" data-url="{{.DeleteBranchLink}}">{{$.locale.Tr "repo.branch.delete" .HeadTarget}}</a>
|
2017-03-17 13:57:43 +08:00
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
{{else if .Issue.IsClosed}}
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item text">
|
2019-04-21 04:50:34 +08:00
|
|
|
{{if .IsPullRequestBroken}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.cant_reopen_deleted_branch"}}
|
2019-04-21 04:50:34 +08:00
|
|
|
{{else}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.reopen_to_merge"}}
|
2019-04-21 04:50:34 +08:00
|
|
|
{{end}}
|
2017-03-17 13:57:43 +08:00
|
|
|
</div>
|
2020-01-08 01:06:14 +08:00
|
|
|
{{if and .IsPullBranchDeletable ( not .IsPullRequestBroken )}}
|
2019-04-21 04:50:34 +08:00
|
|
|
<div class="ui divider"></div>
|
|
|
|
<div>
|
2022-06-28 04:58:46 +08:00
|
|
|
<a class="delete-button ui red button" href="" data-url="{{.DeleteBranchLink}}">{{$.locale.Tr "repo.branch.delete" .HeadTarget}}</a>
|
2019-04-21 04:50:34 +08:00
|
|
|
</div>
|
|
|
|
{{end}}
|
2019-02-05 19:54:49 +08:00
|
|
|
{{else if .IsPullFilesConflicted}}
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item text">
|
2020-09-12 04:19:00 +08:00
|
|
|
{{svg "octicon-x"}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.files_conflicted"}}
|
2023-02-15 23:31:35 +08:00
|
|
|
<ul>
|
|
|
|
{{range .ConflictedFiles}}
|
|
|
|
<li>{{.}}</li>
|
|
|
|
{{end}}
|
|
|
|
</ul>
|
2019-02-05 19:54:49 +08:00
|
|
|
</div>
|
2018-08-01 11:00:35 +08:00
|
|
|
{{else if .IsPullRequestBroken}}
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item">
|
2020-09-12 04:19:00 +08:00
|
|
|
<i class="icon icon-octicon">{{svg "octicon-x"}}</i>
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.data_broken"}}
|
2017-03-17 13:57:43 +08:00
|
|
|
</div>
|
2018-08-14 03:04:39 +08:00
|
|
|
{{else if .IsPullWorkInProgress}}
|
2023-02-14 01:59:59 +08:00
|
|
|
<div class="item toggle-wip gt-df gt-ac gt-sb" data-title="{{.Issue.Title}}" data-wip-prefix="{{(.WorkInProgressPrefix|Escape)}}" data-update-url="{{.Issue.Link}}/title">
|
2021-05-28 04:02:04 +08:00
|
|
|
<div>
|
|
|
|
<i class="icon icon-octicon">{{svg "octicon-x"}}</i>
|
2022-08-31 23:58:54 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.cannot_merge_work_in_progress"}}
|
2021-05-28 04:02:04 +08:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{{if or .HasIssuesOrPullsWritePermission .IsIssuePoster}}
|
|
|
|
<button class="ui compact button">
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.remove_prefix" (.WorkInProgressPrefix|Escape) | Safe}}
|
2021-05-28 04:02:04 +08:00
|
|
|
</button>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
2018-08-14 03:04:39 +08:00
|
|
|
</div>
|
2023-02-03 14:24:45 +08:00
|
|
|
{{template "repo/issue/view_content/update_branch_by_merge" (dict "locale" .locale "Issue" .Issue "UpdateAllowed" .UpdateAllowed "UpdateByRebaseAllowed" .UpdateByRebaseAllowed "Link" .Link)}}
|
2017-03-17 13:57:43 +08:00
|
|
|
{{else if .Issue.PullRequest.IsChecking}}
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item">
|
2020-09-12 04:19:00 +08:00
|
|
|
<i class="icon icon-octicon">{{svg "octicon-sync"}}</i>
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.is_checking"}}
|
2017-03-17 13:57:43 +08:00
|
|
|
</div>
|
2022-07-13 16:22:51 +08:00
|
|
|
{{else if .Issue.PullRequest.IsAncestor}}
|
2021-05-28 04:02:04 +08:00
|
|
|
<div class="item">
|
2021-03-04 11:41:23 +08:00
|
|
|
<i class="icon icon-octicon">{{svg "octicon-alert" 16}}</i>
|
2022-07-13 16:22:51 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.is_ancestor"}}
|
2021-03-04 11:41:23 +08:00
|
|
|
</div>
|
2022-07-13 16:22:51 +08:00
|
|
|
{{else if or .Issue.PullRequest.CanAutoMerge .Issue.PullRequest.IsEmpty}}
|
2020-01-11 15:29:34 +08:00
|
|
|
{{if .IsBlockedByApprovals}}
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item">
|
2020-09-12 04:19:00 +08:00
|
|
|
<i class="icon icon-octicon">{{svg "octicon-x"}}</i>
|
2023-01-16 16:00:22 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.blocked_by_approvals" .GrantedApprovals .ProtectedBranch.RequiredApprovals}}
|
2020-01-11 15:29:34 +08:00
|
|
|
</div>
|
|
|
|
{{else if .IsBlockedByRejection}}
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item">
|
2020-09-12 04:19:00 +08:00
|
|
|
<i class="icon icon-octicon">{{svg "octicon-x"}}</i>
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.blocked_by_rejection"}}
|
2020-01-11 15:29:34 +08:00
|
|
|
</div>
|
2020-11-29 03:30:46 +08:00
|
|
|
{{else if .IsBlockedByOfficialReviewRequests}}
|
|
|
|
<div class="item">
|
|
|
|
<i class="icon icon-octicon">{{svg "octicon-x"}}</i>
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.blocked_by_official_review_requests"}}
|
2020-11-29 03:30:46 +08:00
|
|
|
</div>
|
2020-04-17 09:00:36 +08:00
|
|
|
{{else if .IsBlockedByOutdatedBranch}}
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item">
|
2020-09-12 04:19:00 +08:00
|
|
|
<i class="icon icon-octicon">{{svg "octicon-x"}}</i>
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.blocked_by_outdated_branch"}}
|
2020-04-17 09:00:36 +08:00
|
|
|
</div>
|
2020-10-14 02:50:57 +08:00
|
|
|
{{else if .IsBlockedByChangedProtectedFiles}}
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item">
|
2020-10-14 02:50:57 +08:00
|
|
|
<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
|
2022-08-31 23:58:54 +08:00
|
|
|
{{$.locale.TrN $.ChangedProtectedFilesNum "repo.pulls.blocked_by_changed_protected_files_1" "repo.pulls.blocked_by_changed_protected_files_n" | Safe}}
|
2023-02-15 23:31:35 +08:00
|
|
|
<ul>
|
2020-10-14 02:50:57 +08:00
|
|
|
{{range .ChangedProtectedFiles}}
|
2023-02-15 23:31:35 +08:00
|
|
|
<li>{{.}}</li>
|
2020-10-14 02:50:57 +08:00
|
|
|
{{end}}
|
2023-02-15 23:31:35 +08:00
|
|
|
</ul>
|
2020-10-14 02:50:57 +08:00
|
|
|
</div>
|
2020-01-22 11:46:04 +08:00
|
|
|
{{else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsError .RequiredStatusCheckState.IsFailure)}}
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item">
|
2020-09-12 04:19:00 +08:00
|
|
|
<i class="icon icon-octicon">{{svg "octicon-x"}}</i>
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.required_status_check_failed"}}
|
2020-01-11 15:29:34 +08:00
|
|
|
</div>
|
2020-04-16 04:35:18 +08:00
|
|
|
{{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}}
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item">
|
2020-09-12 04:19:00 +08:00
|
|
|
<i class="icon icon-octicon">{{svg "octicon-x"}}</i>
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.required_status_check_missing"}}
|
2020-04-16 04:35:18 +08:00
|
|
|
</div>
|
2020-08-24 05:59:41 +08:00
|
|
|
{{else if and .AllowMerge .RequireSigned (not .WillSign)}}
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item">
|
2020-09-12 04:19:00 +08:00
|
|
|
<i class="icon icon-octicon">{{svg "octicon-x"}}</i>
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.require_signed_wont_sign"}}
|
2020-01-15 16:32:57 +08:00
|
|
|
</div>
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item">
|
2020-01-18 19:30:35 +08:00
|
|
|
<i class="icon unlock"></i>
|
2022-08-31 23:58:54 +08:00
|
|
|
{{$.locale.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason)}}
|
2020-01-15 16:32:57 +08:00
|
|
|
</div>
|
2019-09-18 13:39:45 +08:00
|
|
|
{{end}}
|
2022-06-11 22:44:20 +08:00
|
|
|
|
2020-11-29 03:30:46 +08:00
|
|
|
{{$notAllOverridableChecksOk := or .IsBlockedByApprovals .IsBlockedByRejection .IsBlockedByOfficialReviewRequests .IsBlockedByOutdatedBranch .IsBlockedByChangedProtectedFiles (and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess))}}
|
2022-06-11 22:44:20 +08:00
|
|
|
|
Fix various typos (#20338)
* Fix various typos
Found via `codespell -q 3 -S ./options/locale,./options/license,./public/vendor -L actived,allways,attachements,ba,befores,commiter,pullrequest,pullrequests,readby,splitted,te,unknwon`
Co-authored-by: zeripath <art27@cantab.net>
2022-07-13 05:32:37 +08:00
|
|
|
{{/* admin can merge without checks, writer can merge when checks succeed */}}
|
2022-06-11 22:44:20 +08:00
|
|
|
{{$canMergeNow := and (or $.IsRepoAdmin (not $notAllOverridableChecksOk)) (or (not .AllowMerge) (not .RequireSigned) .WillSign)}}
|
|
|
|
{{/* admin and writer both can make an auto merge schedule */}}
|
|
|
|
|
|
|
|
{{if $canMergeNow}}
|
2020-01-17 05:01:22 +08:00
|
|
|
{{if $notAllOverridableChecksOk}}
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item">
|
2020-09-12 04:19:00 +08:00
|
|
|
<i class="icon icon-octicon">{{svg "octicon-dot-fill"}}</i>
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.required_status_check_administrator"}}
|
2018-12-27 18:27:08 +08:00
|
|
|
</div>
|
2019-09-18 13:39:45 +08:00
|
|
|
{{else}}
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item">
|
2020-09-12 04:19:00 +08:00
|
|
|
<i class="icon icon-octicon">{{svg "octicon-check"}}</i>
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.can_auto_merge_desc"}}
|
2018-01-06 02:56:50 +08:00
|
|
|
</div>
|
2019-09-18 13:39:45 +08:00
|
|
|
{{end}}
|
2020-01-15 16:32:57 +08:00
|
|
|
{{if .WillSign}}
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item">
|
2020-01-15 16:32:57 +08:00
|
|
|
<i class="icon lock green"></i>
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.signing.will_sign" .SigningKey}}
|
2020-01-15 16:32:57 +08:00
|
|
|
</div>
|
2020-01-16 06:55:25 +08:00
|
|
|
{{else if .IsSigned}}
|
2020-11-16 04:58:16 +08:00
|
|
|
<div class="item">
|
2020-01-18 19:30:35 +08:00
|
|
|
<i class="icon unlock"></i>
|
2022-08-31 23:58:54 +08:00
|
|
|
{{$.locale.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason)}}
|
2020-01-15 16:32:57 +08:00
|
|
|
</div>
|
|
|
|
{{end}}
|
2020-06-14 02:49:59 +08:00
|
|
|
{{end}}
|
2023-02-03 14:24:45 +08:00
|
|
|
{{template "repo/issue/view_content/update_branch_by_merge" (dict "locale" .locale "Issue" .Issue "UpdateAllowed" .UpdateAllowed "UpdateByRebaseAllowed" .UpdateByRebaseAllowed "Link" .Link)}}
|
2022-07-13 16:22:51 +08:00
|
|
|
{{if .Issue.PullRequest.IsEmpty}}
|
|
|
|
<div class="ui divider"></div>
|
|
|
|
|
|
|
|
<div class="item">
|
|
|
|
<i class="icon icon-octicon">{{svg "octicon-alert" 16}}</i>
|
|
|
|
{{$.locale.Tr "repo.pulls.is_empty"}}
|
|
|
|
</div>
|
|
|
|
{{end}}
|
2020-06-14 02:49:59 +08:00
|
|
|
|
2022-06-11 22:44:20 +08:00
|
|
|
{{if .AllowMerge}} {{/* user is allowed to merge */}}
|
2022-12-10 10:46:31 +08:00
|
|
|
{{$prUnit := .Repository.MustGetUnit $.Context $.UnitTypePullRequests}}
|
2022-06-11 22:44:20 +08:00
|
|
|
{{$approvers := .Issue.PullRequest.GetApprovers}}
|
|
|
|
{{if or $prUnit.PullRequestsConfig.AllowMerge $prUnit.PullRequestsConfig.AllowRebase $prUnit.PullRequestsConfig.AllowRebaseMerge $prUnit.PullRequestsConfig.AllowSquash}}
|
|
|
|
{{$hasPendingPullRequestMergeTip := ""}}
|
|
|
|
{{if .HasPendingPullRequestMerge}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$createdPRMergeStr := TimeSinceUnix .PendingPullRequestMerge.CreatedUnix $.locale}}
|
|
|
|
{{$hasPendingPullRequestMergeTip = $.locale.Tr "repo.pulls.auto_merge_has_pending_schedule" .PendingPullRequestMerge.Doer.Name $createdPRMergeStr}}
|
2022-06-11 22:44:20 +08:00
|
|
|
{{end}}
|
|
|
|
<div class="ui divider"></div>
|
2023-02-10 00:31:30 +08:00
|
|
|
<script type="module">
|
|
|
|
const issueUrl = window.location.origin + {{$.Issue.Link}};
|
|
|
|
const defaultMergeTitle = {{.DefaultMergeMessage}};
|
|
|
|
const defaultSquashMergeTitle = {{.DefaultSquashMergeMessage}};
|
|
|
|
const defaultMergeMessage = {{if .DefaultMergeBody}}{{.DefaultMergeBody}}{{else}}`Reviewed-on: ${issueUrl}\n` + {{$approvers}}{{end}};
|
|
|
|
const defaultSquashMergeMessage = {{if .DefaultSquashMergeBody}}{{.DefaultSquashMergeBody}}{{else}}`Reviewed-on: ${issueUrl}\n` + {{$approvers}}{{end}};
|
|
|
|
const mergeForm = {
|
|
|
|
'baseLink': {{.Link}},
|
|
|
|
'textCancel': {{$.locale.Tr "cancel"}},
|
|
|
|
'textDeleteBranch': {{$.locale.Tr "repo.branch.delete" .HeadTarget}},
|
|
|
|
'textAutoMergeButtonWhenSucceed': {{$.locale.Tr "repo.pulls.auto_merge_button_when_succeed"}},
|
|
|
|
'textAutoMergeWhenSucceed': {{$.locale.Tr "repo.pulls.auto_merge_when_succeed"}},
|
|
|
|
'textAutoMergeCancelSchedule': {{$.locale.Tr "repo.pulls.auto_merge_cancel_schedule"}},
|
|
|
|
'textClearMergeMessage': {{$.locale.Tr "repo.pulls.clear_merge_message"}},
|
|
|
|
'textClearMergeMessageHint': {{$.locale.Tr "repo.pulls.clear_merge_message_hint"}},
|
2022-05-12 21:39:02 +08:00
|
|
|
|
2023-02-10 00:31:30 +08:00
|
|
|
'canMergeNow': {{$canMergeNow}},
|
|
|
|
'allOverridableChecksOk': {{not $notAllOverridableChecksOk}},
|
|
|
|
'emptyCommit': {{.Issue.PullRequest.IsEmpty}},
|
|
|
|
'pullHeadCommitID': {{.PullHeadCommitID}},
|
|
|
|
'isPullBranchDeletable': {{.IsPullBranchDeletable}},
|
|
|
|
'defaultMergeStyle': {{.MergeStyle}},
|
|
|
|
'defaultDeleteBranchAfterMerge': {{$prUnit.PullRequestsConfig.DefaultDeleteBranchAfterMerge}},
|
|
|
|
'mergeMessageFieldPlaceHolder': {{$.locale.Tr "repo.editor.commit_message_desc"}},
|
|
|
|
'defaultMergeMessage': defaultMergeMessage,
|
2022-05-12 21:39:02 +08:00
|
|
|
|
2023-02-10 00:31:30 +08:00
|
|
|
'hasPendingPullRequestMerge': {{.HasPendingPullRequestMerge}},
|
|
|
|
'hasPendingPullRequestMergeTip': {{$hasPendingPullRequestMergeTip}},
|
|
|
|
};
|
2022-05-12 21:39:02 +08:00
|
|
|
|
2023-02-14 01:59:59 +08:00
|
|
|
const generalHideAutoMerge = mergeForm.canMergeNow && mergeForm.allOverridableChecksOk; // if this pr can be merged now, then hide the auto merge
|
2023-02-10 00:31:30 +08:00
|
|
|
mergeForm['mergeStyles'] = [
|
|
|
|
{
|
|
|
|
'name': 'merge',
|
|
|
|
'allowed': {{$prUnit.PullRequestsConfig.AllowMerge}},
|
|
|
|
'textDoMerge': {{$.locale.Tr "repo.pulls.merge_pull_request"}},
|
|
|
|
'mergeTitleFieldText': defaultMergeTitle,
|
|
|
|
'mergeMessageFieldText': defaultMergeMessage,
|
|
|
|
'hideAutoMerge': generalHideAutoMerge,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name': 'rebase',
|
|
|
|
'allowed': {{$prUnit.PullRequestsConfig.AllowRebase}},
|
|
|
|
'textDoMerge': {{$.locale.Tr "repo.pulls.rebase_merge_pull_request"}},
|
|
|
|
'hideMergeMessageTexts': true,
|
|
|
|
'hideAutoMerge': generalHideAutoMerge,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name': 'rebase-merge',
|
|
|
|
'allowed': {{$prUnit.PullRequestsConfig.AllowRebaseMerge}},
|
|
|
|
'textDoMerge': {{$.locale.Tr "repo.pulls.rebase_merge_commit_pull_request"}},
|
|
|
|
'mergeTitleFieldText': defaultMergeTitle,
|
|
|
|
'mergeMessageFieldText': defaultMergeMessage,
|
|
|
|
'hideAutoMerge': generalHideAutoMerge,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name': 'squash',
|
|
|
|
'allowed': {{$prUnit.PullRequestsConfig.AllowSquash}},
|
|
|
|
'textDoMerge': {{$.locale.Tr "repo.pulls.squash_merge_pull_request"}},
|
|
|
|
'mergeTitleFieldText': defaultSquashMergeTitle,
|
|
|
|
'mergeMessageFieldText': {{.GetCommitMessages}} + defaultSquashMergeMessage,
|
|
|
|
'hideAutoMerge': generalHideAutoMerge,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name': 'manually-merged',
|
|
|
|
'allowed': {{and $prUnit.PullRequestsConfig.AllowManualMerge $.IsRepoAdmin}},
|
|
|
|
'textDoMerge': {{$.locale.Tr "repo.pulls.merge_manually"}},
|
|
|
|
'hideMergeMessageTexts': true,
|
|
|
|
'hideAutoMerge': true,
|
|
|
|
}
|
|
|
|
];
|
|
|
|
window.config.pageData.pullRequestMergeForm = mergeForm;
|
2022-06-11 22:44:20 +08:00
|
|
|
</script>
|
2022-05-12 21:39:02 +08:00
|
|
|
|
2022-06-11 22:44:20 +08:00
|
|
|
<div id="pull-request-merge-form"></div>
|
2020-01-11 15:29:34 +08:00
|
|
|
{{else}}
|
2022-06-11 22:44:20 +08:00
|
|
|
{{/* no merge style was set in repo setting: not or ($prUnit.PullRequestsConfig.AllowMerge ...) */}}
|
2020-06-14 02:49:59 +08:00
|
|
|
<div class="ui divider"></div>
|
2022-06-11 22:44:20 +08:00
|
|
|
<div class="item text red">
|
|
|
|
{{svg "octicon-x"}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.no_merge_desc"}}
|
2022-06-11 22:44:20 +08:00
|
|
|
</div>
|
2021-05-28 04:02:04 +08:00
|
|
|
<div class="item">
|
2020-09-12 04:19:00 +08:00
|
|
|
{{svg "octicon-info"}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.no_merge_helper"}}
|
2020-01-11 15:29:34 +08:00
|
|
|
</div>
|
2022-06-11 22:44:20 +08:00
|
|
|
{{end}} {{/* end if the repo was set to use any merge style */}}
|
|
|
|
{{else}}
|
|
|
|
{{/* user is not allowed to merge */}}
|
|
|
|
<div class="ui divider"></div>
|
|
|
|
<div class="item">
|
|
|
|
{{svg "octicon-info"}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.no_merge_access"}}
|
2022-06-11 22:44:20 +08:00
|
|
|
</div>
|
|
|
|
{{end}} {{/* end if user is allowed to merge or not */}}
|
2017-03-17 13:57:43 +08:00
|
|
|
{{else}}
|
2020-01-11 15:29:34 +08:00
|
|
|
{{/* Merge conflict without specific file. Suggest manual merge, only if all reviews and status checks OK. */}}
|
|
|
|
{{if .IsBlockedByApprovals}}
|
|
|
|
<div class="item text red">
|
2020-09-12 04:19:00 +08:00
|
|
|
{{svg "octicon-x"}}
|
2023-01-16 16:00:22 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.blocked_by_approvals" .GrantedApprovals .ProtectedBranch.RequiredApprovals}}
|
2020-01-11 15:29:34 +08:00
|
|
|
</div>
|
|
|
|
{{else if .IsBlockedByRejection}}
|
|
|
|
<div class="item text red">
|
2020-09-12 04:19:00 +08:00
|
|
|
{{svg "octicon-x"}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.blocked_by_rejection"}}
|
2020-11-29 03:30:46 +08:00
|
|
|
</div>
|
|
|
|
{{else if .IsBlockedByOfficialReviewRequests}}
|
|
|
|
<div class="item text red">
|
|
|
|
{{svg "octicon-x"}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.blocked_by_official_review_requests"}}
|
2020-01-11 15:29:34 +08:00
|
|
|
</div>
|
2020-04-17 09:00:36 +08:00
|
|
|
{{else if .IsBlockedByOutdatedBranch}}
|
|
|
|
<div class="item text red">
|
2020-09-12 04:19:00 +08:00
|
|
|
<i class="icon icon-octicon">{{svg "octicon-x"}}</i>
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.blocked_by_outdated_branch"}}
|
2020-04-17 09:00:36 +08:00
|
|
|
</div>
|
2020-10-14 02:50:57 +08:00
|
|
|
{{else if .IsBlockedByChangedProtectedFiles}}
|
|
|
|
<div class="item text red">
|
|
|
|
<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
|
2022-08-31 23:58:54 +08:00
|
|
|
{{$.locale.TrN $.ChangedProtectedFilesNum "repo.pulls.blocked_by_changed_protected_files_1" "repo.pulls.blocked_by_changed_protected_files_n" | Safe}}
|
2023-02-15 23:31:35 +08:00
|
|
|
<ul>
|
2020-10-14 02:50:57 +08:00
|
|
|
{{range .ChangedProtectedFiles}}
|
2023-02-15 23:31:35 +08:00
|
|
|
<li>{{.}}</li>
|
2020-10-14 02:50:57 +08:00
|
|
|
{{end}}
|
2023-02-15 23:31:35 +08:00
|
|
|
</ul>
|
2020-10-14 02:50:57 +08:00
|
|
|
</div>
|
2020-04-16 04:35:18 +08:00
|
|
|
{{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}}
|
2020-01-11 15:29:34 +08:00
|
|
|
<div class="item text red">
|
2020-09-12 04:19:00 +08:00
|
|
|
{{svg "octicon-x"}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.required_status_check_failed"}}
|
2020-01-11 15:29:34 +08:00
|
|
|
</div>
|
2020-01-15 16:32:57 +08:00
|
|
|
{{else if and .RequireSigned (not .WillSign)}}
|
|
|
|
<div class="item text red">
|
2020-09-12 04:19:00 +08:00
|
|
|
{{svg "octicon-x"}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.require_signed_wont_sign"}}
|
2020-01-15 16:32:57 +08:00
|
|
|
</div>
|
2020-01-11 15:29:34 +08:00
|
|
|
{{else}}
|
|
|
|
<div class="item text red">
|
2020-09-12 04:19:00 +08:00
|
|
|
{{svg "octicon-x"}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.cannot_auto_merge_desc"}}
|
2020-01-11 15:29:34 +08:00
|
|
|
</div>
|
2021-05-28 04:02:04 +08:00
|
|
|
<div class="item">
|
2020-09-12 04:19:00 +08:00
|
|
|
{{svg "octicon-info"}}
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.cannot_auto_merge_helper"}}
|
2020-01-11 15:29:34 +08:00
|
|
|
</div>
|
|
|
|
{{end}}
|
2017-03-17 13:57:43 +08:00
|
|
|
{{end}}
|
2020-06-14 02:49:59 +08:00
|
|
|
|
2021-03-04 11:41:23 +08:00
|
|
|
{{if $.StillCanManualMerge}}
|
|
|
|
<div class="ui divider"></div>
|
|
|
|
<div class="ui form manually-merged-fields" style="display: none">
|
|
|
|
<form action="{{.Link}}/merge" method="post">
|
|
|
|
{{.CsrfTokenHtml}}
|
|
|
|
<div class="field">
|
2022-06-28 04:58:46 +08:00
|
|
|
<input type="text" name="merge_commit_id" placeholder="{{$.locale.Tr "repo.pulls.merge_commit_id"}}">
|
2021-03-04 11:41:23 +08:00
|
|
|
</div>
|
|
|
|
<button class="ui red button" type="submit" name="do" value="manually-merged">
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.merge_manually"}}
|
2021-03-04 11:41:23 +08:00
|
|
|
</button>
|
|
|
|
<button class="ui button merge-cancel">
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "cancel"}}
|
2021-03-04 11:41:23 +08:00
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="ui red buttons merge-button">
|
|
|
|
<button class="ui button" data-do="manually-merged">
|
2022-06-28 04:58:46 +08:00
|
|
|
{{$.locale.Tr "repo.pulls.merge_manually"}}
|
2021-03-04 11:41:23 +08:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
2023-02-15 23:31:35 +08:00
|
|
|
|
|
|
|
{{if and .ShowMergeInstructions .Issue.PullRequest.HeadRepo}}
|
|
|
|
{{template "repo/issue/view_content/pull_merge_instruction" (dict "locale" .locale "Issue" .Issue)}}
|
|
|
|
{{end}}
|
2017-03-17 13:57:43 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|