Skip to content

Commit a7851d3

Browse files
authored
Merge branch 'main' into api_repoGetTag
2 parents 2086d96 + be81dc8 commit a7851d3

22 files changed

+260
-131
lines changed

.drone.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: compliance
44

55
platform:
66
os: linux
7-
arch: arm64
7+
arch: amd64
88

99
trigger:
1010
event:
@@ -27,7 +27,7 @@ steps:
2727

2828
- name: lint-backend
2929
pull: always
30-
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env
30+
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env
3131
commands:
3232
- make lint-backend
3333
environment:
@@ -37,7 +37,7 @@ steps:
3737

3838
- name: lint-backend-windows
3939
pull: always
40-
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env
40+
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env
4141
commands:
4242
- make golangci-lint vet
4343
environment:
@@ -49,7 +49,7 @@ steps:
4949

5050
- name: lint-backend-gogit
5151
pull: always
52-
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env
52+
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env
5353
commands:
5454
- make lint-backend
5555
environment:

models/action.go

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,32 @@ type ActionType int
2626

2727
// Possible action types.
2828
const (
29-
ActionCreateRepo ActionType = iota + 1 // 1
30-
ActionRenameRepo // 2
31-
ActionStarRepo // 3
32-
ActionWatchRepo // 4
33-
ActionCommitRepo // 5
34-
ActionCreateIssue // 6
35-
ActionCreatePullRequest // 7
36-
ActionTransferRepo // 8
37-
ActionPushTag // 9
38-
ActionCommentIssue // 10
39-
ActionMergePullRequest // 11
40-
ActionCloseIssue // 12
41-
ActionReopenIssue // 13
42-
ActionClosePullRequest // 14
43-
ActionReopenPullRequest // 15
44-
ActionDeleteTag // 16
45-
ActionDeleteBranch // 17
46-
ActionMirrorSyncPush // 18
47-
ActionMirrorSyncCreate // 19
48-
ActionMirrorSyncDelete // 20
49-
ActionApprovePullRequest // 21
50-
ActionRejectPullRequest // 22
51-
ActionCommentPull // 23
52-
ActionPublishRelease // 24
53-
ActionPullReviewDismissed // 25
29+
ActionCreateRepo ActionType = iota + 1 // 1
30+
ActionRenameRepo // 2
31+
ActionStarRepo // 3
32+
ActionWatchRepo // 4
33+
ActionCommitRepo // 5
34+
ActionCreateIssue // 6
35+
ActionCreatePullRequest // 7
36+
ActionTransferRepo // 8
37+
ActionPushTag // 9
38+
ActionCommentIssue // 10
39+
ActionMergePullRequest // 11
40+
ActionCloseIssue // 12
41+
ActionReopenIssue // 13
42+
ActionClosePullRequest // 14
43+
ActionReopenPullRequest // 15
44+
ActionDeleteTag // 16
45+
ActionDeleteBranch // 17
46+
ActionMirrorSyncPush // 18
47+
ActionMirrorSyncCreate // 19
48+
ActionMirrorSyncDelete // 20
49+
ActionApprovePullRequest // 21
50+
ActionRejectPullRequest // 22
51+
ActionCommentPull // 23
52+
ActionPublishRelease // 24
53+
ActionPullReviewDismissed // 25
54+
ActionPullRequestReadyForReview // 26
5455
)
5556

5657
// Action represents user operation type and other information to

models/notification.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,14 @@ func createOrUpdateIssueNotifications(e Engine, issueID, commentID, notification
207207
for _, id := range issueWatches {
208208
toNotify[id] = struct{}{}
209209
}
210-
211-
repoWatches, err := getRepoWatchersIDs(e, issue.RepoID)
212-
if err != nil {
213-
return err
214-
}
215-
for _, id := range repoWatches {
216-
toNotify[id] = struct{}{}
210+
if !(issue.IsPull && HasWorkInProgressPrefix(issue.Title)) {
211+
repoWatches, err := getRepoWatchersIDs(e, issue.RepoID)
212+
if err != nil {
213+
return err
214+
}
215+
for _, id := range repoWatches {
216+
toNotify[id] = struct{}{}
217+
}
217218
}
218219
issueParticipants, err := issue.getParticipantIDsByIssue(e)
219220
if err != nil {

models/pull.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,13 @@ func (pr *PullRequest) IsWorkInProgress() bool {
595595
log.Error("LoadIssue: %v", err)
596596
return false
597597
}
598+
return HasWorkInProgressPrefix(pr.Issue.Title)
599+
}
598600

601+
// HasWorkInProgressPrefix determines if the given PR title has a Work In Progress prefix
602+
func HasWorkInProgressPrefix(title string) bool {
599603
for _, prefix := range setting.Repository.PullRequest.WorkInProgressPrefixes {
600-
if strings.HasPrefix(strings.ToUpper(pr.Issue.Title), prefix) {
604+
if strings.HasPrefix(strings.ToUpper(title), prefix) {
601605
return true
602606
}
603607
}

modules/markup/html.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -304,27 +304,26 @@ func postProcess(ctx *RenderContext, procs []processor, input io.Reader, output
304304
_, _ = res.WriteString("</body></html>")
305305

306306
// parse the HTML
307-
nodes, err := html.ParseFragment(res, nil)
307+
node, err := html.Parse(res)
308308
if err != nil {
309309
return &postProcessError{"invalid HTML", err}
310310
}
311311

312-
for _, node := range nodes {
313-
visitNode(ctx, procs, node, true)
312+
if node.Type == html.DocumentNode {
313+
node = node.FirstChild
314314
}
315315

316-
newNodes := make([]*html.Node, 0, len(nodes))
316+
visitNode(ctx, procs, node, true)
317317

318-
for _, node := range nodes {
319-
if node.Data == "html" {
320-
node = node.FirstChild
321-
for node != nil && node.Data != "body" {
322-
node = node.NextSibling
323-
}
324-
}
325-
if node == nil {
326-
continue
318+
newNodes := make([]*html.Node, 0, 5)
319+
320+
if node.Data == "html" {
321+
node = node.FirstChild
322+
for node != nil && node.Data != "body" {
323+
node = node.NextSibling
327324
}
325+
}
326+
if node != nil {
328327
if node.Data == "body" {
329328
child := node.FirstChild
330329
for child != nil {

modules/notification/mail/mail.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ func (m *mailNotifier) NotifyIssueChangeStatus(doer *models.User, issue *models.
7373
}
7474
}
7575

76+
func (m *mailNotifier) NotifyIssueChangeTitle(doer *models.User, issue *models.Issue, oldTitle string) {
77+
if err := issue.LoadPullRequest(); err != nil {
78+
log.Error("issue.LoadPullRequest: %v", err)
79+
return
80+
}
81+
if issue.IsPull && models.HasWorkInProgressPrefix(oldTitle) && !issue.PullRequest.IsWorkInProgress() {
82+
if err := mailer.MailParticipants(issue, doer, models.ActionPullRequestReadyForReview, nil); err != nil {
83+
log.Error("MailParticipants: %v", err)
84+
}
85+
}
86+
}
87+
7688
func (m *mailNotifier) NotifyNewPullRequest(pr *models.PullRequest, mentions []*models.User) {
7789
if err := mailer.MailParticipants(pr.Issue, pr.Issue.Poster, models.ActionCreatePullRequest, mentions); err != nil {
7890
log.Error("MailParticipants: %v", err)

modules/notification/ui/ui.go

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,19 @@ func (ns *notificationService) NotifyIssueChangeStatus(doer *models.User, issue
9494
})
9595
}
9696

97+
func (ns *notificationService) NotifyIssueChangeTitle(doer *models.User, issue *models.Issue, oldTitle string) {
98+
if err := issue.LoadPullRequest(); err != nil {
99+
log.Error("issue.LoadPullRequest: %v", err)
100+
return
101+
}
102+
if issue.IsPull && models.HasWorkInProgressPrefix(oldTitle) && !issue.PullRequest.IsWorkInProgress() {
103+
_ = ns.issueQueue.Push(issueNotificationOpts{
104+
IssueID: issue.ID,
105+
NotificationAuthorID: doer.ID,
106+
})
107+
}
108+
}
109+
97110
func (ns *notificationService) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User) {
98111
_ = ns.issueQueue.Push(issueNotificationOpts{
99112
IssueID: pr.Issue.ID,
@@ -106,15 +119,32 @@ func (ns *notificationService) NotifyNewPullRequest(pr *models.PullRequest, ment
106119
log.Error("Unable to load issue: %d for pr: %d: Error: %v", pr.IssueID, pr.ID, err)
107120
return
108121
}
109-
_ = ns.issueQueue.Push(issueNotificationOpts{
110-
IssueID: pr.Issue.ID,
111-
NotificationAuthorID: pr.Issue.PosterID,
112-
})
122+
toNotify := make(map[int64]struct{}, 32)
123+
repoWatchers, err := models.GetRepoWatchersIDs(pr.Issue.RepoID)
124+
if err != nil {
125+
log.Error("GetRepoWatchersIDs: %v", err)
126+
return
127+
}
128+
for _, id := range repoWatchers {
129+
toNotify[id] = struct{}{}
130+
}
131+
issueParticipants, err := models.GetParticipantsIDsByIssueID(pr.IssueID)
132+
if err != nil {
133+
log.Error("GetParticipantsIDsByIssueID: %v", err)
134+
return
135+
}
136+
for _, id := range issueParticipants {
137+
toNotify[id] = struct{}{}
138+
}
139+
delete(toNotify, pr.Issue.PosterID)
113140
for _, mention := range mentions {
141+
toNotify[mention.ID] = struct{}{}
142+
}
143+
for receiverID := range toNotify {
114144
_ = ns.issueQueue.Push(issueNotificationOpts{
115145
IssueID: pr.Issue.ID,
116146
NotificationAuthorID: pr.Issue.PosterID,
117-
ReceiverID: mention.ID,
147+
ReceiverID: receiverID,
118148
})
119149
}
120150
}

options/locale/locale_en-US.ini

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,19 +317,64 @@ password_pwned = The password you chose is on a <a target="_blank" rel="noopener
317317
password_pwned_err = Could not complete request to HaveIBeenPwned
318318
319319
[mail]
320+
view_it_on = View it on %s
321+
link_not_working_do_paste = Not working? Try copying and pasting it to your browser.
322+
hi_user_x = Hi <b>%s</b>,
323+
320324
activate_account = Please activate your account
325+
activate_account.title = %s, please activate your account
326+
activate_account.test_1 = Hi <b>%[1]s</b>, thanks for registering at %[2]s!
327+
activate_account.test_2 = Please click the following link to activate your account within <b>%s</b>:
328+
321329
activate_email = Verify your email address
330+
activate_email.title = %s, please verify your e-mail address
331+
activate_email.text = Please click the following link to verify your email address within <b>%s</b>:
332+
333+
register_notify = Welcome to Gitea
334+
register_notify.title = %[1]s, welcome to %[2]s
335+
register_notify.text_1 = this is your registration confirmation email for %s!
336+
register_notify.text_2 = You can now login via username: %s.
337+
register_notify.text_3 = If this account has been created for you, please <a href="%s">set your password</a> first.
338+
322339
reset_password = Recover your account
340+
reset_password.title = %s, you have requested to recover your account
341+
reset_password.text = Please click the following link to recover your account within <b>%s</b>:
342+
323343
register_success = Registration successful
324-
register_notify = Welcome to Gitea
344+
345+
issue_assigned.pull = @%[1]s assigned you to the pull request %[2]s in repository %[3]s.
346+
issue_assigned.issue = @%[1]s assigned you to the issue %[2]s in repository %[3]s.
347+
348+
issue.x_mentioned_you = <b>@%s</b> mentioned you:
349+
issue.action.force_push = <b>%[1]s</b> force-pushed the <b>%[2]s</b> from %[3]s to %[4]s.
350+
issue.action.push_1 = <b>@%[1]s</b> pushed 1 commit to %[2]s
351+
issue.action.push_n = <b>@%[1]s</b> pushed %[3]d commits to %s: %[2]s
352+
issue.action.close = <b>@%[1]s</b> closed #%[2]d.
353+
issue.action.reopen = <b>@%[1]s</b> reopened #%[2]d.
354+
issue.action.merge = <b>@%[1]s</b> merged #%[2]d into #%[3]s.
355+
issue.action.approve = <b>@%[1]s</b> approved this pull request.
356+
issue.action.reject = <b>@%[1]s</b> requested changes on this pull request.
357+
issue.action.review = <b>@%[1]s</b> commented on this pull request.
358+
issue.action.review_dismissed = <b>@%[1]s</b> dismissed last review from %[2]s for this pull request.
359+
issue.action.ready_for_review = <b>@%[1]s</b> marked this pull request ready for review.
360+
issue.action.new = Created #%[2]d.
361+
issue.in_tree_path = In %s:
325362
326363
release.new.subject = %s in %s released
364+
release.new.text = <b>@%[1]s</b> released %[2]s in %[3]s
365+
release.title = Title: %s
366+
release.note = Note:
367+
release.downloads = Downloads:
368+
release.download.zip = Source Code (ZIP)
369+
release.download.targz = Source Code (TAR.GZ)
327370
328371
repo.transfer.subject_to = %s would like to transfer "%s" to %s
329372
repo.transfer.subject_to_you = %s would like to transfer "%s" to you
330373
repo.transfer.to_you = you
374+
repo.transfer.body = To accept or reject it visit %s or just ignore it.
331375
332376
repo.collaborator.added.subject = %s added you to %s
377+
repo.collaborator.added.text = You have been added as a collaborator of repository:
333378
334379
[modal]
335380
yes = Yes

0 commit comments

Comments
 (0)