From a15f0cb010ac394cb238e95f913d47aba455f55e Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 18 Dec 2021 07:59:08 +0800 Subject: [PATCH] Fix rename notification bug (#18011) --- modules/notification/action/action.go | 2 -- services/repository/transfer.go | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/notification/action/action.go b/modules/notification/action/action.go index 776bee6a0c..2d0f6810da 100644 --- a/modules/notification/action/action.go +++ b/modules/notification/action/action.go @@ -148,8 +148,6 @@ func (a *actionNotifier) NotifyNewPullRequest(pull *models.PullRequest, mentions } 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, diff --git a/services/repository/transfer.go b/services/repository/transfer.go index bb323c1c0a..5c29b60365 100644 --- a/services/repository/transfer.go +++ b/services/repository/transfer.go @@ -8,6 +8,7 @@ import ( "fmt" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/sync" ) @@ -53,6 +54,8 @@ func TransferOwnership(doer, newOwner *models.User, repo *models.Repository, tea // ChangeRepositoryName changes all corresponding setting from old repository name to new one. func ChangeRepositoryName(doer *models.User, repo *models.Repository, newRepoName string) error { + log.Trace("ChangeRepositoryName: %s/%s -> %s", doer.Name, repo.Name, newRepoName) + oldRepoName := repo.Name // Change repository directory name. We must lock the local copy of the @@ -66,6 +69,7 @@ func ChangeRepositoryName(doer *models.User, repo *models.Repository, newRepoNam } repoWorkingPool.CheckOut(fmt.Sprint(repo.ID)) + repo.Name = newRepoName notification.NotifyRenameRepository(doer, repo, oldRepoName) return nil