Skip to content

Commit

Permalink
Merge branch 'main' into api_repoGetTag
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 committed Jun 23, 2021
2 parents 2086d96 + be81dc8 commit a7851d3
Show file tree
Hide file tree
Showing 22 changed files with 260 additions and 131 deletions.
8 changes: 4 additions & 4 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: compliance

platform:
os: linux
arch: arm64
arch: amd64

trigger:
event:
Expand All @@ -27,7 +27,7 @@ steps:

- name: lint-backend
pull: always
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env
commands:
- make lint-backend
environment:
Expand All @@ -37,7 +37,7 @@ steps:

- name: lint-backend-windows
pull: always
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env
commands:
- make golangci-lint vet
environment:
Expand All @@ -49,7 +49,7 @@ steps:

- name: lint-backend-gogit
pull: always
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env
commands:
- make lint-backend
environment:
Expand Down
51 changes: 26 additions & 25 deletions models/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,32 @@ type ActionType int

// Possible action types.
const (
ActionCreateRepo ActionType = iota + 1 // 1
ActionRenameRepo // 2
ActionStarRepo // 3
ActionWatchRepo // 4
ActionCommitRepo // 5
ActionCreateIssue // 6
ActionCreatePullRequest // 7
ActionTransferRepo // 8
ActionPushTag // 9
ActionCommentIssue // 10
ActionMergePullRequest // 11
ActionCloseIssue // 12
ActionReopenIssue // 13
ActionClosePullRequest // 14
ActionReopenPullRequest // 15
ActionDeleteTag // 16
ActionDeleteBranch // 17
ActionMirrorSyncPush // 18
ActionMirrorSyncCreate // 19
ActionMirrorSyncDelete // 20
ActionApprovePullRequest // 21
ActionRejectPullRequest // 22
ActionCommentPull // 23
ActionPublishRelease // 24
ActionPullReviewDismissed // 25
ActionCreateRepo ActionType = iota + 1 // 1
ActionRenameRepo // 2
ActionStarRepo // 3
ActionWatchRepo // 4
ActionCommitRepo // 5
ActionCreateIssue // 6
ActionCreatePullRequest // 7
ActionTransferRepo // 8
ActionPushTag // 9
ActionCommentIssue // 10
ActionMergePullRequest // 11
ActionCloseIssue // 12
ActionReopenIssue // 13
ActionClosePullRequest // 14
ActionReopenPullRequest // 15
ActionDeleteTag // 16
ActionDeleteBranch // 17
ActionMirrorSyncPush // 18
ActionMirrorSyncCreate // 19
ActionMirrorSyncDelete // 20
ActionApprovePullRequest // 21
ActionRejectPullRequest // 22
ActionCommentPull // 23
ActionPublishRelease // 24
ActionPullReviewDismissed // 25
ActionPullRequestReadyForReview // 26
)

// Action represents user operation type and other information to
Expand Down
15 changes: 8 additions & 7 deletions models/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,14 @@ func createOrUpdateIssueNotifications(e Engine, issueID, commentID, notification
for _, id := range issueWatches {
toNotify[id] = struct{}{}
}

repoWatches, err := getRepoWatchersIDs(e, issue.RepoID)
if err != nil {
return err
}
for _, id := range repoWatches {
toNotify[id] = struct{}{}
if !(issue.IsPull && HasWorkInProgressPrefix(issue.Title)) {
repoWatches, err := getRepoWatchersIDs(e, issue.RepoID)
if err != nil {
return err
}
for _, id := range repoWatches {
toNotify[id] = struct{}{}
}
}
issueParticipants, err := issue.getParticipantIDsByIssue(e)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion models/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,13 @@ func (pr *PullRequest) IsWorkInProgress() bool {
log.Error("LoadIssue: %v", err)
return false
}
return HasWorkInProgressPrefix(pr.Issue.Title)
}

// HasWorkInProgressPrefix determines if the given PR title has a Work In Progress prefix
func HasWorkInProgressPrefix(title string) bool {
for _, prefix := range setting.Repository.PullRequest.WorkInProgressPrefixes {
if strings.HasPrefix(strings.ToUpper(pr.Issue.Title), prefix) {
if strings.HasPrefix(strings.ToUpper(title), prefix) {
return true
}
}
Expand Down
25 changes: 12 additions & 13 deletions modules/markup/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,27 +304,26 @@ func postProcess(ctx *RenderContext, procs []processor, input io.Reader, output
_, _ = res.WriteString("</body></html>")

// parse the HTML
nodes, err := html.ParseFragment(res, nil)
node, err := html.Parse(res)
if err != nil {
return &postProcessError{"invalid HTML", err}
}

for _, node := range nodes {
visitNode(ctx, procs, node, true)
if node.Type == html.DocumentNode {
node = node.FirstChild
}

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

for _, node := range nodes {
if node.Data == "html" {
node = node.FirstChild
for node != nil && node.Data != "body" {
node = node.NextSibling
}
}
if node == nil {
continue
newNodes := make([]*html.Node, 0, 5)

if node.Data == "html" {
node = node.FirstChild
for node != nil && node.Data != "body" {
node = node.NextSibling
}
}
if node != nil {
if node.Data == "body" {
child := node.FirstChild
for child != nil {
Expand Down
12 changes: 12 additions & 0 deletions modules/notification/mail/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ func (m *mailNotifier) NotifyIssueChangeStatus(doer *models.User, issue *models.
}
}

func (m *mailNotifier) NotifyIssueChangeTitle(doer *models.User, issue *models.Issue, oldTitle string) {
if err := issue.LoadPullRequest(); err != nil {
log.Error("issue.LoadPullRequest: %v", err)
return
}
if issue.IsPull && models.HasWorkInProgressPrefix(oldTitle) && !issue.PullRequest.IsWorkInProgress() {
if err := mailer.MailParticipants(issue, doer, models.ActionPullRequestReadyForReview, nil); err != nil {
log.Error("MailParticipants: %v", err)
}
}
}

func (m *mailNotifier) NotifyNewPullRequest(pr *models.PullRequest, mentions []*models.User) {
if err := mailer.MailParticipants(pr.Issue, pr.Issue.Poster, models.ActionCreatePullRequest, mentions); err != nil {
log.Error("MailParticipants: %v", err)
Expand Down
40 changes: 35 additions & 5 deletions modules/notification/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ func (ns *notificationService) NotifyIssueChangeStatus(doer *models.User, issue
})
}

func (ns *notificationService) NotifyIssueChangeTitle(doer *models.User, issue *models.Issue, oldTitle string) {
if err := issue.LoadPullRequest(); err != nil {
log.Error("issue.LoadPullRequest: %v", err)
return
}
if issue.IsPull && models.HasWorkInProgressPrefix(oldTitle) && !issue.PullRequest.IsWorkInProgress() {
_ = ns.issueQueue.Push(issueNotificationOpts{
IssueID: issue.ID,
NotificationAuthorID: doer.ID,
})
}
}

func (ns *notificationService) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User) {
_ = ns.issueQueue.Push(issueNotificationOpts{
IssueID: pr.Issue.ID,
Expand All @@ -106,15 +119,32 @@ func (ns *notificationService) NotifyNewPullRequest(pr *models.PullRequest, ment
log.Error("Unable to load issue: %d for pr: %d: Error: %v", pr.IssueID, pr.ID, err)
return
}
_ = ns.issueQueue.Push(issueNotificationOpts{
IssueID: pr.Issue.ID,
NotificationAuthorID: pr.Issue.PosterID,
})
toNotify := make(map[int64]struct{}, 32)
repoWatchers, err := models.GetRepoWatchersIDs(pr.Issue.RepoID)
if err != nil {
log.Error("GetRepoWatchersIDs: %v", err)
return
}
for _, id := range repoWatchers {
toNotify[id] = struct{}{}
}
issueParticipants, err := models.GetParticipantsIDsByIssueID(pr.IssueID)
if err != nil {
log.Error("GetParticipantsIDsByIssueID: %v", err)
return
}
for _, id := range issueParticipants {
toNotify[id] = struct{}{}
}
delete(toNotify, pr.Issue.PosterID)
for _, mention := range mentions {
toNotify[mention.ID] = struct{}{}
}
for receiverID := range toNotify {
_ = ns.issueQueue.Push(issueNotificationOpts{
IssueID: pr.Issue.ID,
NotificationAuthorID: pr.Issue.PosterID,
ReceiverID: mention.ID,
ReceiverID: receiverID,
})
}
}
Expand Down
47 changes: 46 additions & 1 deletion options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -317,19 +317,64 @@ password_pwned = The password you chose is on a <a target="_blank" rel="noopener
password_pwned_err = Could not complete request to HaveIBeenPwned
[mail]
view_it_on = View it on %s
link_not_working_do_paste = Not working? Try copying and pasting it to your browser.
hi_user_x = Hi <b>%s</b>,
activate_account = Please activate your account
activate_account.title = %s, please activate your account
activate_account.test_1 = Hi <b>%[1]s</b>, thanks for registering at %[2]s!
activate_account.test_2 = Please click the following link to activate your account within <b>%s</b>:
activate_email = Verify your email address
activate_email.title = %s, please verify your e-mail address
activate_email.text = Please click the following link to verify your email address within <b>%s</b>:
register_notify = Welcome to Gitea
register_notify.title = %[1]s, welcome to %[2]s
register_notify.text_1 = this is your registration confirmation email for %s!
register_notify.text_2 = You can now login via username: %s.
register_notify.text_3 = If this account has been created for you, please <a href="%s">set your password</a> first.
reset_password = Recover your account
reset_password.title = %s, you have requested to recover your account
reset_password.text = Please click the following link to recover your account within <b>%s</b>:
register_success = Registration successful
register_notify = Welcome to Gitea
issue_assigned.pull = @%[1]s assigned you to the pull request %[2]s in repository %[3]s.
issue_assigned.issue = @%[1]s assigned you to the issue %[2]s in repository %[3]s.
issue.x_mentioned_you = <b>@%s</b> mentioned you:
issue.action.force_push = <b>%[1]s</b> force-pushed the <b>%[2]s</b> from %[3]s to %[4]s.
issue.action.push_1 = <b>@%[1]s</b> pushed 1 commit to %[2]s
issue.action.push_n = <b>@%[1]s</b> pushed %[3]d commits to %s: %[2]s
issue.action.close = <b>@%[1]s</b> closed #%[2]d.
issue.action.reopen = <b>@%[1]s</b> reopened #%[2]d.
issue.action.merge = <b>@%[1]s</b> merged #%[2]d into #%[3]s.
issue.action.approve = <b>@%[1]s</b> approved this pull request.
issue.action.reject = <b>@%[1]s</b> requested changes on this pull request.
issue.action.review = <b>@%[1]s</b> commented on this pull request.
issue.action.review_dismissed = <b>@%[1]s</b> dismissed last review from %[2]s for this pull request.
issue.action.ready_for_review = <b>@%[1]s</b> marked this pull request ready for review.
issue.action.new = Created #%[2]d.
issue.in_tree_path = In %s:
release.new.subject = %s in %s released
release.new.text = <b>@%[1]s</b> released %[2]s in %[3]s
release.title = Title: %s
release.note = Note:
release.downloads = Downloads:
release.download.zip = Source Code (ZIP)
release.download.targz = Source Code (TAR.GZ)
repo.transfer.subject_to = %s would like to transfer "%s" to %s
repo.transfer.subject_to_you = %s would like to transfer "%s" to you
repo.transfer.to_you = you
repo.transfer.body = To accept or reject it visit %s or just ignore it.
repo.collaborator.added.subject = %s added you to %s
repo.collaborator.added.text = You have been added as a collaborator of repository:
[modal]
yes = Yes
Expand Down
Loading

0 comments on commit a7851d3

Please sign in to comment.