Browse Source

[refactor] notify remove unused praram (#9804)

tags/v1.12.0-dev
6543 Antoine GIRARD 5 years ago
parent
commit
cb49c54436
9 changed files with 10 additions and 22 deletions
  1. +1
    -2
      modules/notification/action/action.go
  2. +1
    -2
      modules/notification/base/notifier.go
  3. +1
    -2
      modules/notification/base/null.go
  4. +1
    -2
      modules/notification/mail/mail.go
  5. +2
    -3
      modules/notification/notification.go
  6. +1
    -2
      modules/notification/ui/ui.go
  7. +1
    -1
      modules/notification/webhook/webhook.go
  8. +1
    -7
      services/pull/check.go
  9. +1
    -1
      services/pull/merge.go

+ 1
- 2
modules/notification/action/action.go View File

@@ -11,7 +11,6 @@ import (
"strings" "strings"


"code.gitea.io/gitea/models" "code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification/base" "code.gitea.io/gitea/modules/notification/base"
"code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/repository"
@@ -253,7 +252,7 @@ func (a *actionNotifier) NotifyPullRequestReview(pr *models.PullRequest, review
} }
} }


func (*actionNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User, baseRepo *git.Repository) {
func (*actionNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User) {
if err := models.NotifyWatchers(&models.Action{ if err := models.NotifyWatchers(&models.Action{
ActUserID: doer.ID, ActUserID: doer.ID,
ActUser: doer, ActUser: doer,


+ 1
- 2
modules/notification/base/notifier.go View File

@@ -6,7 +6,6 @@ package base


import ( import (
"code.gitea.io/gitea/models" "code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/repository"
) )


@@ -32,7 +31,7 @@ type Notifier interface {
addedLabels []*models.Label, removedLabels []*models.Label) addedLabels []*models.Label, removedLabels []*models.Label)


NotifyNewPullRequest(*models.PullRequest) NotifyNewPullRequest(*models.PullRequest)
NotifyMergePullRequest(*models.PullRequest, *models.User, *git.Repository)
NotifyMergePullRequest(*models.PullRequest, *models.User)
NotifyPullRequestSynchronized(doer *models.User, pr *models.PullRequest) NotifyPullRequestSynchronized(doer *models.User, pr *models.PullRequest)
NotifyPullRequestReview(*models.PullRequest, *models.Review, *models.Comment) NotifyPullRequestReview(*models.PullRequest, *models.Review, *models.Comment)
NotifyPullRequestChangeTargetBranch(doer *models.User, pr *models.PullRequest, oldBranch string) NotifyPullRequestChangeTargetBranch(doer *models.User, pr *models.PullRequest, oldBranch string)


+ 1
- 2
modules/notification/base/null.go View File

@@ -6,7 +6,6 @@ package base


import ( import (
"code.gitea.io/gitea/models" "code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/repository"
) )


@@ -44,7 +43,7 @@ func (*NullNotifier) NotifyPullRequestReview(pr *models.PullRequest, r *models.R
} }


// NotifyMergePullRequest places a place holder function // NotifyMergePullRequest places a place holder function
func (*NullNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User, baseRepo *git.Repository) {
func (*NullNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User) {
} }


// NotifyPullRequestSynchronized places a place holder function // NotifyPullRequestSynchronized places a place holder function


+ 1
- 2
modules/notification/mail/mail.go View File

@@ -8,7 +8,6 @@ import (
"fmt" "fmt"


"code.gitea.io/gitea/models" "code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification/base" "code.gitea.io/gitea/modules/notification/base"
"code.gitea.io/gitea/services/mailer" "code.gitea.io/gitea/services/mailer"
@@ -101,7 +100,7 @@ func (m *mailNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *model
} }
} }


func (m *mailNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User, baseRepo *git.Repository) {
func (m *mailNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User) {
if err := pr.LoadIssue(); err != nil { if err := pr.LoadIssue(); err != nil {
log.Error("pr.LoadIssue: %v", err) log.Error("pr.LoadIssue: %v", err)
return return


+ 2
- 3
modules/notification/notification.go View File

@@ -6,7 +6,6 @@ package notification


import ( import (
"code.gitea.io/gitea/models" "code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/notification/action" "code.gitea.io/gitea/modules/notification/action"
"code.gitea.io/gitea/modules/notification/base" "code.gitea.io/gitea/modules/notification/base"
"code.gitea.io/gitea/modules/notification/indexer" "code.gitea.io/gitea/modules/notification/indexer"
@@ -61,9 +60,9 @@ func NotifyIssueChangeStatus(doer *models.User, issue *models.Issue, actionComme
} }


// NotifyMergePullRequest notifies merge pull request to notifiers // NotifyMergePullRequest notifies merge pull request to notifiers
func NotifyMergePullRequest(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repository) {
func NotifyMergePullRequest(pr *models.PullRequest, doer *models.User) {
for _, notifier := range notifiers { for _, notifier := range notifiers {
notifier.NotifyMergePullRequest(pr, doer, baseGitRepo)
notifier.NotifyMergePullRequest(pr, doer)
} }
} }




+ 1
- 2
modules/notification/ui/ui.go View File

@@ -6,7 +6,6 @@ package ui


import ( import (
"code.gitea.io/gitea/models" "code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification/base" "code.gitea.io/gitea/modules/notification/base"
) )
@@ -69,7 +68,7 @@ func (ns *notificationService) NotifyIssueChangeStatus(doer *models.User, issue
} }
} }


func (ns *notificationService) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User, gitRepo *git.Repository) {
func (ns *notificationService) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User) {
ns.issueQueue <- issueNotificationOpts{ ns.issueQueue <- issueNotificationOpts{
issueID: pr.Issue.ID, issueID: pr.Issue.ID,
notificationAuthorID: doer.ID, notificationAuthorID: doer.ID,


+ 1
- 1
modules/notification/webhook/webhook.go View File

@@ -523,7 +523,7 @@ func (m *webhookNotifier) NotifyPushCommits(pusher *models.User, repo *models.Re
} }
} }


func (*webhookNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User, baseRepo *git.Repository) {
func (*webhookNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User) {
// Reload pull request information. // Reload pull request information.
if err := pr.LoadAttributes(); err != nil { if err := pr.LoadAttributes(); err != nil {
log.Error("LoadAttributes: %v", err) log.Error("LoadAttributes: %v", err)


+ 1
- 7
services/pull/check.go View File

@@ -147,13 +147,7 @@ func manuallyMerged(pr *models.PullRequest) bool {
return false return false
} }


baseGitRepo, err := git.OpenRepository(pr.BaseRepo.RepoPath())
if err != nil {
log.Error("OpenRepository[%s] : %v", pr.BaseRepo.RepoPath(), err)
return false
}

notification.NotifyMergePullRequest(pr, merger, baseGitRepo)
notification.NotifyMergePullRequest(pr, merger)


log.Info("manuallyMerged[%d]: Marked as manually merged into %s/%s by commit id: %s", pr.ID, pr.BaseRepo.Name, pr.BaseBranch, commit.ID.String()) log.Info("manuallyMerged[%d]: Marked as manually merged into %s/%s by commit id: %s", pr.ID, pr.BaseRepo.Name, pr.BaseBranch, commit.ID.String())
return true return true


+ 1
- 1
services/pull/merge.go View File

@@ -350,7 +350,7 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor
log.Error("setMerged [%d]: %v", pr.ID, err) log.Error("setMerged [%d]: %v", pr.ID, err)
} }


notification.NotifyMergePullRequest(pr, doer, baseGitRepo)
notification.NotifyMergePullRequest(pr, doer)


// Reset cached commit count // Reset cached commit count
cache.Remove(pr.Issue.Repo.GetCommitsCountCacheKey(pr.BaseBranch, true)) cache.Remove(pr.Issue.Repo.GetCommitsCountCacheKey(pr.BaseBranch, true))


Loading…
Cancel
Save