mirror of https://github.com/gogs/gogs.git
repo/setting: filter out deleted branch in protect list (#4288)
parent
431e930367
commit
7c802f6d83
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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…
Reference in New Issue