Browse Source

repo/setting: filter out deleted branch in protect list (#4288)

pull/4301/head
Unknwon 8 years ago
parent
commit
7c802f6d83
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 10
      routers/repo/setting.go
  2. 2
      templates/repo/settings/branches.tmpl

10
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)
}

2
templates/repo/settings/branches.tmpl

@ -50,7 +50,7 @@
<div class="ui protected-branches list">
{{range .ProtectBranches}}
<div class="item">
<a href="{{$.Link}}/{{.Name}}"><code>{{.Name}}</code></a>
<a href="{{$.Link}}/{{.}}"><code>{{.}}</code></a>
</div>
{{end}}
</div>

Loading…
Cancel
Save