Fix bug when pushing mirror with wiki (#36795) (#36807)

Fix #36736
Backport #36795

Co-authored-by: ChristopherHX <christopher.homberger@web.de>
This commit is contained in:
Lunny Xiao
2026-03-06 16:26:34 +01:00
committed by GitHub
co-authored by ChristopherHX
parent 5552eff6e7
commit 3c46a3deb3
3 changed files with 53 additions and 1 deletions
+5 -1
View File
@@ -149,7 +149,11 @@ func preReceiveBranch(ctx *preReceiveContext, oldCommitID, newCommitID string, r
gitRepo := ctx.Repo.GitRepo
objectFormat := ctx.Repo.GetObjectFormat()
if branchName == repo.DefaultBranch && newCommitID == objectFormat.EmptyObjectID().String() {
defaultBranch := repo.DefaultBranch
if ctx.opts.IsWiki && repo.DefaultWikiBranch != "" {
defaultBranch = repo.DefaultWikiBranch
}
if branchName == defaultBranch && newCommitID == objectFormat.EmptyObjectID().String() {
log.Warn("Forbidden: Branch: %s is the default branch in %-v and cannot be deleted", branchName, repo)
ctx.JSON(http.StatusForbidden, private.Response{
UserMsg: fmt.Sprintf("branch %s is the default branch and cannot be deleted", branchName),