mirror of
https://github.com/go-gitea/gitea.git
synced 2026-02-07 09:49:41 +09:00
Fix CODEOWNERS review request attribution using comment metadata (#36348)
Fixes #36333 ## Problem When CODEOWNERS automatically assigns reviewers to a pull request, the timeline incorrectly shows the PR author as the one who requested the review (e.g., "PR_AUTHOR requested review from CODE_OWNER"). This is misleading since the action was triggered automatically by CODEOWNERS rules, not by the PR author. ## Solution Store CODEOWNERS attribution in comment metadata instead of changing the doer user: - Add `SpecialDoerName` field to `CommentMetaData` struct (value: `"CODEOWNERS"` for CODEOWNERS-triggered requests) - Pass `isCodeOwners=true` to `AddReviewRequest` and `AddTeamReviewRequest` functions - Template can check this metadata to show appropriate attribution message --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
committed by
GitHub
parent
49edbbbc2e
commit
65422fde4d
@@ -40,14 +40,14 @@
|
||||
{{end}}
|
||||
</span>
|
||||
|
||||
<span class="author flex-text-inline">
|
||||
<span class="flex-text-inline tw-text-12">
|
||||
{{$userName := $commit.Commit.Author.Name}}
|
||||
{{if $commit.User}}
|
||||
{{if and $commit.User.FullName DefaultShowFullName}}
|
||||
{{$userName = $commit.User.FullName}}
|
||||
{{end}}
|
||||
{{ctx.AvatarUtils.Avatar $commit.User 18}}
|
||||
<a href="{{$commit.User.HomeLink}}">{{$userName}}</a>
|
||||
<a class="muted" href="{{$commit.User.HomeLink}}">{{$userName}}</a>
|
||||
{{else}}
|
||||
{{ctx.AvatarUtils.AvatarByEmail $commit.Commit.Author.Email $userName 18}}
|
||||
{{$userName}}
|
||||
|
||||
@@ -514,32 +514,20 @@
|
||||
{{else if eq .Type 27}}
|
||||
<div class="timeline-item event" id="{{.HashTag}}">
|
||||
<span class="badge">{{svg "octicon-eye"}}</span>
|
||||
{{template "shared/user/avatarlink" dict "user" .Poster}}
|
||||
<span class="comment-text-line">
|
||||
{{template "shared/user/authorlink" .Poster}}
|
||||
{{if (gt .AssigneeID 0)}}
|
||||
{{if .RemovedAssignee}}
|
||||
{{if eq .PosterID .AssigneeID}}
|
||||
{{ctx.Locale.Tr "repo.issues.review.remove_review_request_self" $createdStr}}
|
||||
{{else}}
|
||||
{{ctx.Locale.Tr "repo.issues.review.remove_review_request" .Assignee.GetDisplayName $createdStr}}
|
||||
{{end}}
|
||||
{{else}}
|
||||
{{ctx.Locale.Tr "repo.issues.review.add_review_request" .Assignee.GetDisplayName $createdStr}}
|
||||
{{end}}
|
||||
{{else}}
|
||||
<!-- If the assigned team is deleted, just displaying "Ghost Team" in the comment -->
|
||||
{{$teamName := "Ghost Team"}}
|
||||
{{if .AssigneeTeam}}
|
||||
{{$teamName = .AssigneeTeam.Name}}
|
||||
{{end}}
|
||||
{{if .RemovedAssignee}}
|
||||
{{ctx.Locale.Tr "repo.issues.review.remove_review_request" $teamName $createdStr}}
|
||||
{{else}}
|
||||
{{ctx.Locale.Tr "repo.issues.review.add_review_request" $teamName $createdStr}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
</span>
|
||||
{{$specialDoerHtml := .MetaSpecialDoerTr ctx.Locale}}
|
||||
{{$timelineRequestedReviewHtml := .TimelineRequestedReviewTr ctx.Locale $createdStr}}
|
||||
{{if $specialDoerHtml}}
|
||||
<span class="comment-text-line">
|
||||
{{$specialDoerHtml}}
|
||||
{{$timelineRequestedReviewHtml}}
|
||||
</span>
|
||||
{{else}}
|
||||
{{template "shared/user/avatarlink" dict "user" .Poster}}
|
||||
<span class="comment-text-line">
|
||||
{{template "shared/user/authorlink" .Poster}}
|
||||
{{$timelineRequestedReviewHtml}}
|
||||
</span>
|
||||
{{end}}
|
||||
</div>
|
||||
{{else if and (eq .Type 29) (or (gt .CommitsNum 0) .IsForcePush)}}
|
||||
<!-- If PR is closed, the comments whose type is CommentTypePullRequestPush(29) after latestCloseCommentID won't be rendered. //-->
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a class="author text black tw-font-semibold muted"{{if gt .ID 0}} href="{{.HomeLink}}"{{end}}>{{.GetDisplayName}}</a>{{if .IsTypeBot}}<span class="ui basic label tw-p-1 tw-align-baseline">bot</span>{{end}}
|
||||
<a class="muted text black tw-font-semibold"{{if gt .ID 0}} href="{{.HomeLink}}"{{end}}>{{.GetDisplayName}}</a>{{if .IsTypeBot}}<span class="ui basic label tw-p-1 tw-align-baseline">bot</span>{{end}}
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a class="avatar-with-link" {{if gt .user.ID 0}}href="{{.user.HomeLink}}"{{end}}>{{ctx.AvatarUtils.Avatar .user}}</a>
|
||||
<a class="avatar-with-link" {{if gt .user.ID 0}}href="{{.user.HomeLink}}"{{end}}>{{ctx.AvatarUtils.Avatar .user (or .size 20)}}</a>
|
||||
|
||||
Reference in New Issue
Block a user