Move transfer repository and rename repository on a service package and start action notification (#8573)

* move transfer repository and rename repository on a service package and start action notification

* remove unused codes

* fix lint

* fix bugs

* fix test

* fix test

* fix test

* fix lint

* update go mod and sum
This commit is contained in:
Lunny Xiao 2019-11-15 16:06:11 +08:00 committed by GitHub
parent b30d744e09
commit 21ae9838e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 216 additions and 253 deletions

View file

@ -6,6 +6,7 @@ package action
import (
"fmt"
"path"
"strings"
"code.gitea.io/gitea/models"
@ -77,7 +78,9 @@ func (a *actionNotifier) NotifyNewPullRequest(pull *models.PullRequest) {
}
}
func (a *actionNotifier) NotifyRenameRepository(doer *models.User, repo *models.Repository, oldName string) {
func (a *actionNotifier) NotifyRenameRepository(doer *models.User, repo *models.Repository, oldRepoName string) {
log.Trace("action.ChangeRepositoryName: %s/%s", doer.Name, repo.Name)
if err := models.NotifyWatchers(&models.Action{
ActUserID: doer.ID,
ActUser: doer,
@ -85,11 +88,23 @@ func (a *actionNotifier) NotifyRenameRepository(doer *models.User, repo *models.
RepoID: repo.ID,
Repo: repo,
IsPrivate: repo.IsPrivate,
Content: oldName,
Content: oldRepoName,
}); err != nil {
log.Error("notify watchers: %v", err)
} else {
log.Trace("action.renameRepoAction: %s/%s", doer.Name, repo.Name)
log.Error("NotifyWatchers: %v", err)
}
}
func (a *actionNotifier) NotifyTransferRepository(doer *models.User, repo *models.Repository, oldOwnerName string) {
if err := models.NotifyWatchers(&models.Action{
ActUserID: doer.ID,
ActUser: doer,
OpType: models.ActionTransferRepo,
RepoID: repo.ID,
Repo: repo,
IsPrivate: repo.IsPrivate,
Content: path.Join(oldOwnerName, repo.Name),
}); err != nil {
log.Error("NotifyWatchers: %v", err)
}
}