Skip to content

[refactor] notify remove unused praram #9804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions modules/notification/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"strings"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification/base"
"code.gitea.io/gitea/modules/repository"
Expand Down Expand Up @@ -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{
ActUserID: doer.ID,
ActUser: doer,
Expand Down
3 changes: 1 addition & 2 deletions modules/notification/base/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package base

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

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

NotifyNewPullRequest(*models.PullRequest)
NotifyMergePullRequest(*models.PullRequest, *models.User, *git.Repository)
NotifyMergePullRequest(*models.PullRequest, *models.User)
NotifyPullRequestSynchronized(doer *models.User, pr *models.PullRequest)
NotifyPullRequestReview(*models.PullRequest, *models.Review, *models.Comment)
NotifyPullRequestChangeTargetBranch(doer *models.User, pr *models.PullRequest, oldBranch string)
Expand Down
3 changes: 1 addition & 2 deletions modules/notification/base/null.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package base

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

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

// 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
Expand Down
3 changes: 1 addition & 2 deletions modules/notification/mail/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification/base"
"code.gitea.io/gitea/services/mailer"
Expand Down Expand Up @@ -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 {
log.Error("pr.LoadIssue: %v", err)
return
Expand Down
5 changes: 2 additions & 3 deletions modules/notification/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package notification

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

// 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 {
notifier.NotifyMergePullRequest(pr, doer, baseGitRepo)
notifier.NotifyMergePullRequest(pr, doer)
}
}

Expand Down
3 changes: 1 addition & 2 deletions modules/notification/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package ui

import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification/base"
)
Expand Down Expand Up @@ -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{
issueID: pr.Issue.ID,
notificationAuthorID: doer.ID,
Expand Down
2 changes: 1 addition & 1 deletion modules/notification/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
if err := pr.LoadAttributes(); err != nil {
log.Error("LoadAttributes: %v", err)
Expand Down
8 changes: 1 addition & 7 deletions services/pull/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,7 @@ func manuallyMerged(pr *models.PullRequest) bool {
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())
return true
Expand Down
2 changes: 1 addition & 1 deletion services/pull/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor
log.Error("setMerged [%d]: %v", pr.ID, err)
}

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

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