mirror of
https://github.com/go-gitea/gitea
synced 2026-02-03 08:50:36 +00:00
Add new comment types for WIP prefix changes
- Added CommentTypeMarkedAsWorkInProgress and CommentTypeMarkedAsReadyForReview - Updated ChangeIssueTitle to detect WIP prefix changes - Added locale strings for the new messages - Updated template to render new comment types Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
This commit is contained in:
@@ -116,6 +116,9 @@ const (
|
||||
CommentTypeUnpin // 37 unpin Issue/PullRequest
|
||||
|
||||
CommentTypeChangeTimeEstimate // 38 Change time estimate
|
||||
|
||||
CommentTypeMarkedAsWorkInProgress // 39 Mark PR as work in progress
|
||||
CommentTypeMarkedAsReadyForReview // 40 Mark PR as ready for review
|
||||
)
|
||||
|
||||
var commentStrings = []string{
|
||||
@@ -158,6 +161,8 @@ var commentStrings = []string{
|
||||
"pin",
|
||||
"unpin",
|
||||
"change_time_estimate",
|
||||
"marked_as_work_in_progress",
|
||||
"marked_as_ready_for_review",
|
||||
}
|
||||
|
||||
func (t CommentType) String() string {
|
||||
|
||||
@@ -209,8 +209,23 @@ func ChangeIssueTitle(ctx context.Context, issue *Issue, doer *user_model.User,
|
||||
return fmt.Errorf("loadRepo: %w", err)
|
||||
}
|
||||
|
||||
// Determine the comment type based on WIP prefix changes for pull requests
|
||||
commentType := CommentTypeChangeTitle
|
||||
if issue.IsPull {
|
||||
hadWIP := HasWorkInProgressPrefix(oldTitle)
|
||||
hasWIP := HasWorkInProgressPrefix(issue.Title)
|
||||
|
||||
if !hadWIP && hasWIP {
|
||||
// WIP prefix was added
|
||||
commentType = CommentTypeMarkedAsWorkInProgress
|
||||
} else if hadWIP && !hasWIP {
|
||||
// WIP prefix was removed
|
||||
commentType = CommentTypeMarkedAsReadyForReview
|
||||
}
|
||||
}
|
||||
|
||||
opts := &CreateCommentOptions{
|
||||
Type: CommentTypeChangeTitle,
|
||||
Type: commentType,
|
||||
Doer: doer,
|
||||
Repo: issue.Repo,
|
||||
Issue: issue,
|
||||
|
||||
@@ -1447,6 +1447,8 @@
|
||||
"repo.issues.remove_assignee_at": "was unassigned by <b>%s</b> %s",
|
||||
"repo.issues.remove_self_assignment": "removed their assignment %s",
|
||||
"repo.issues.change_title_at": "changed title from <b><strike>%s</strike></b> to <b>%s</b> %s",
|
||||
"repo.issues.marked_as_work_in_progress": "marked the pull request as work in progress %s",
|
||||
"repo.issues.marked_as_ready_for_review": "marked the pull request as ready for review %s",
|
||||
"repo.issues.change_ref_at": "changed reference from <b><strike>%s</strike></b> to <b>%s</b> %s",
|
||||
"repo.issues.remove_ref_at": "removed reference <b>%s</b> %s",
|
||||
"repo.issues.add_ref_at": "added reference <b>%s</b> %s",
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
29 = PULL_PUSH_EVENT, 30 = PROJECT_CHANGED, 31 = PROJECT_BOARD_CHANGED
|
||||
32 = DISMISSED_REVIEW, 33 = COMMENT_TYPE_CHANGE_ISSUE_REF, 34 = PR_SCHEDULE_TO_AUTO_MERGE,
|
||||
35 = CANCEL_SCHEDULED_AUTO_MERGE_PR, 36 = PIN_ISSUE, 37 = UNPIN_ISSUE,
|
||||
38 = COMMENT_TYPE_CHANGE_TIME_ESTIMATE -->
|
||||
38 = COMMENT_TYPE_CHANGE_TIME_ESTIMATE, 39 = MARKED_AS_WORK_IN_PROGRESS,
|
||||
40 = MARKED_AS_READY_FOR_REVIEW -->
|
||||
{{if eq .Type 0}}
|
||||
<div class="timeline-item comment" id="{{.HashTag}}">
|
||||
{{if .OriginalAuthor}}
|
||||
@@ -692,6 +693,24 @@
|
||||
{{end}}
|
||||
</span>
|
||||
</div>
|
||||
{{else if eq .Type 39}}
|
||||
<div class="timeline-item event" id="{{.HashTag}}">
|
||||
<span class="badge">{{svg "octicon-x-circle"}}</span>
|
||||
{{template "shared/user/avatarlink" dict "user" .Poster}}
|
||||
<span class="comment-text-line">
|
||||
{{template "shared/user/authorlink" .Poster}}
|
||||
{{ctx.Locale.Tr "repo.issues.marked_as_work_in_progress" $createdStr}}
|
||||
</span>
|
||||
</div>
|
||||
{{else if eq .Type 40}}
|
||||
<div class="timeline-item event" id="{{.HashTag}}">
|
||||
<span class="badge">{{svg "octicon-check-circle"}}</span>
|
||||
{{template "shared/user/avatarlink" dict "user" .Poster}}
|
||||
<span class="comment-text-line">
|
||||
{{template "shared/user/authorlink" .Poster}}
|
||||
{{ctx.Locale.Tr "repo.issues.marked_as_ready_for_review" $createdStr}}
|
||||
</span>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
Reference in New Issue
Block a user