Unify repo names in system notices (#36491)

Fixes: https://github.com/go-gitea/gitea/issues/36211

This PR fixes ensures that all system notices consistently include
repository names in the format `"Action description (owner/repo): error
message"`.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
Copilot
2026-02-01 17:06:57 +08:00
committed by GitHub
parent e377da989f
commit 072de7d8cd
10 changed files with 25 additions and 24 deletions
+6 -6
View File
@@ -265,8 +265,8 @@ func CreateRepositoryDirectly(ctx context.Context, doer, owner *user_model.User,
// WARNING: Don't override all later err with local variables
defer func() {
if err != nil {
// we can not use the ctx because it maybe canceled or timeout
cleanupRepository(repo.ID)
// we can not use `ctx` because it may be canceled or timed out
cleanupRepository(repo)
}
}()
@@ -461,11 +461,11 @@ func createRepositoryInDB(ctx context.Context, doer, u *user_model.User, repo *r
return nil
}
func cleanupRepository(repoID int64) {
if errDelete := DeleteRepositoryDirectly(graceful.GetManager().ShutdownContext(), repoID); errDelete != nil {
func cleanupRepository(repo *repo_model.Repository) {
ctx := graceful.GetManager().ShutdownContext()
if errDelete := DeleteRepositoryDirectly(ctx, repo.ID); errDelete != nil {
log.Error("cleanupRepository failed: %v", errDelete)
// add system notice
if err := system_model.CreateRepositoryNotice("DeleteRepositoryDirectly failed when cleanup repository: %v", errDelete); err != nil {
if err := system_model.CreateRepositoryNotice("DeleteRepositoryDirectly failed when cleanup repository (%s)", repo.FullName(), errDelete); err != nil {
log.Error("CreateRepositoryNotice: %v", err)
}
}