diff options
author | Unknwon <u@gogs.io> | 2017-03-16 20:09:27 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-03-16 20:09:27 -0400 |
commit | 7c802f6d83b50e5a647fbf667c25480d67f4791f (patch) | |
tree | f1fef4b653908b8af1e40a4ee1ca83b62fc70a16 | |
parent | 431e930367dccbc9c3df4afbc370b2b05482d231 (diff) |
repo/setting: filter out deleted branch in protect list (#4288)
-rw-r--r-- | routers/repo/setting.go | 10 | ||||
-rw-r--r-- | templates/repo/settings/branches.tmpl | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go index c52be187..eb139476 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 e5d6c1fb..92149b08 100644 --- a/templates/repo/settings/branches.tmpl +++ b/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> |