fix:branch_tag_count

This commit is contained in:
hang 2021-10-14 11:37:54 +08:00
parent 6576006a78
commit 52d9414a29
2 changed files with 4 additions and 8 deletions

View File

@ -702,7 +702,6 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/*", viewfile.ReadmeByPath) // reqRepoReader(models.UnitTypeCode),
})
m.Group("/count", func() {
m.Get("", viewfile.CommitCount) //****
})
@ -717,7 +716,6 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/contributors", func() {
m.Get("", report.GetContributors) //获取仓库的所有构建者信息 ****
})
m.Combo("").Get(reqAnyRepoReader(), repo.Get).
Delete(reqToken(), reqOwner(), repo.Delete).
Patch(reqToken(), reqAdmin(), bind(api.EditRepoOption{}), context.RepoRef(), repo.Edit)
@ -725,7 +723,6 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Combo("/notifications").
Get(reqToken(), notify.ListRepoNotifications).
Put(reqToken(), notify.ReadRepoNotifications)
m.Group("/wikies", func() {
m.Combo("").Get(repo.WikiList).
Post(bind(api.WikiOption{}), repo.CreateWiki)
@ -809,6 +806,9 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/tags", func() {
m.Get("", repo.ListTags)
}, reqRepoReader(models.UnitTypeCode), context.ReferencesGitRepo(true))
m.Group("/branch_tag_count", func() {
m.Get("", repo.GetRepoBranchAndTagCount)
}, reqRepoReader(models.UnitTypeCode), context.ReferencesGitRepo(true))
m.Group("/keys", func() {
m.Combo("").Get(repo.ListDeployKeys).
Post(bind(api.CreateKeyOption{}), repo.CreateDeployKey)

View File

@ -157,12 +157,8 @@ func GetRepoBranchAndTagCount(ctx *context.APIContext) {
ctx.ServerError("GetBranches", err)
return
}
var branchCount int
for range branches {
branchCount += 1
}
result := api.RepoBranchAndTagCount{
BranchCount: branchCount,
BranchCount: len(branches),
TagCount: tagsCountTotal,
}
ctx.JSON(http.StatusOK, result)