diff --git a/routers/repo/setting.go b/routers/repo/setting.go index c52be187d..eb1394765 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -373,7 +373,15 @@ func SettingsBranches(ctx *context.Context) { ctx.Handle(500, "GetProtectBranchesByRepoID", err) return } - ctx.Data["ProtectBranches"] = protectBranches + + // Filter out deleted branches + branches := make([]string, 0, len(protectBranches)) + for i := range protectBranches { + if ctx.Repo.GitRepo.IsBranchExist(protectBranches[i].Name) { + branches = append(branches, protectBranches[i].Name) + } + } + ctx.Data["ProtectBranches"] = branches ctx.HTML(200, SETTINGS_BRANCHES) } diff --git a/templates/repo/settings/branches.tmpl b/templates/repo/settings/branches.tmpl index e5d6c1fb8..92149b08d 100644 --- a/templates/repo/settings/branches.tmpl +++ b/templates/repo/settings/branches.tmpl @@ -50,7 +50,7 @@
{{range .ProtectBranches}}
- {{.Name}} + {{.}}
{{end}}