From d17ccd443449aa74bf7d22bbc993016f77a88e86 Mon Sep 17 00:00:00 2001 From: yousimu Date: Tue, 25 Aug 2026 18:01:16 +0800 Subject: [PATCH] fix(repo): prevent MarkAsBrokenEmpty when repository is being migrated (#39091) --- services/context/repo.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/context/repo.go b/services/context/repo.go index f79ab39cc74..61ffbb22f79 100644 --- a/services/context/repo.go +++ b/services/context/repo.go @@ -695,6 +695,12 @@ func repoAssignmentPrepareGitRepo(ctx *Context, data *repoAssignmentPrepareDataS ctx.Repo.GitRepo, err = git.RepositoryFromRequestContextOrOpen(ctx, repo) if err != nil { if strings.Contains(err.Error(), "repository does not exist") || strings.Contains(err.Error(), "no such file or directory") { + // A repository that is still being created (migrated or forked) does not have its + // git data on disk yet, so opening it fails. This is expected and must not be + // treated as a permanently broken repository. + if ctx.Repo.Repository.IsBeingCreated() { + return + } log.Error("Repository %-v has a broken repository on the file system: %s Error: %v", ctx.Repo.Repository, ctx.Repo.Repository.FullName(), err) ctx.Repo.Repository.MarkAsBrokenEmpty() // Only allow access to base of repo or settings