forked from Gitlink/gitea-1120-rc1
Merge pull request '新增/{repo}/branch_tag_count接口' (#32) from wonderful/gitea-1120-rc1:fix_pulls into develop
This commit is contained in:
commit
987ac773f6
|
@ -8,6 +8,12 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//add
|
||||||
|
type RepoBranchAndTagCount struct {
|
||||||
|
BranchCount int `json:"branch_count"`
|
||||||
|
TagCount int64 `json:"tag_count"`
|
||||||
|
}
|
||||||
|
|
||||||
// Permission represents a set of permissions
|
// Permission represents a set of permissions
|
||||||
type Permission struct {
|
type Permission struct {
|
||||||
Admin bool `json:"admin"`
|
Admin bool `json:"admin"`
|
||||||
|
|
|
@ -702,7 +702,6 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
m.Get("/*", viewfile.ReadmeByPath) // reqRepoReader(models.UnitTypeCode),
|
m.Get("/*", viewfile.ReadmeByPath) // reqRepoReader(models.UnitTypeCode),
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
m.Group("/count", func() {
|
m.Group("/count", func() {
|
||||||
m.Get("", viewfile.CommitCount) //****
|
m.Get("", viewfile.CommitCount) //****
|
||||||
})
|
})
|
||||||
|
@ -717,7 +716,6 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
m.Group("/contributors", func() {
|
m.Group("/contributors", func() {
|
||||||
m.Get("", report.GetContributors) //获取仓库的所有构建者信息 ****
|
m.Get("", report.GetContributors) //获取仓库的所有构建者信息 ****
|
||||||
})
|
})
|
||||||
|
|
||||||
m.Combo("").Get(reqAnyRepoReader(), repo.Get).
|
m.Combo("").Get(reqAnyRepoReader(), repo.Get).
|
||||||
Delete(reqToken(), reqOwner(), repo.Delete).
|
Delete(reqToken(), reqOwner(), repo.Delete).
|
||||||
Patch(reqToken(), reqAdmin(), bind(api.EditRepoOption{}), context.RepoRef(), repo.Edit)
|
Patch(reqToken(), reqAdmin(), bind(api.EditRepoOption{}), context.RepoRef(), repo.Edit)
|
||||||
|
@ -725,7 +723,6 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
m.Combo("/notifications").
|
m.Combo("/notifications").
|
||||||
Get(reqToken(), notify.ListRepoNotifications).
|
Get(reqToken(), notify.ListRepoNotifications).
|
||||||
Put(reqToken(), notify.ReadRepoNotifications)
|
Put(reqToken(), notify.ReadRepoNotifications)
|
||||||
|
|
||||||
m.Group("/wikies", func() {
|
m.Group("/wikies", func() {
|
||||||
m.Combo("").Get(repo.WikiList).
|
m.Combo("").Get(repo.WikiList).
|
||||||
Post(bind(api.WikiOption{}), repo.CreateWiki)
|
Post(bind(api.WikiOption{}), repo.CreateWiki)
|
||||||
|
@ -809,6 +806,9 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
m.Group("/tags", func() {
|
m.Group("/tags", func() {
|
||||||
m.Get("", repo.ListTags)
|
m.Get("", repo.ListTags)
|
||||||
}, reqRepoReader(models.UnitTypeCode), context.ReferencesGitRepo(true))
|
}, 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.Group("/keys", func() {
|
||||||
m.Combo("").Get(repo.ListDeployKeys).
|
m.Combo("").Get(repo.ListDeployKeys).
|
||||||
Post(bind(api.CreateKeyOption{}), repo.CreateDeployKey)
|
Post(bind(api.CreateKeyOption{}), repo.CreateDeployKey)
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
"code.gitea.io/gitea/modules/convert"
|
"code.gitea.io/gitea/modules/convert"
|
||||||
|
repo_module "code.gitea.io/gitea/modules/repository"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
"code.gitea.io/gitea/routers/api/v1/utils"
|
"code.gitea.io/gitea/routers/api/v1/utils"
|
||||||
)
|
)
|
||||||
|
@ -123,3 +124,42 @@ func GetTag(ctx *context.APIContext) {
|
||||||
ctx.JSON(http.StatusOK, convert.ToAnnotatedTag(ctx.Repo.Repository, tag, commit))
|
ctx.JSON(http.StatusOK, convert.ToAnnotatedTag(ctx.Repo.Repository, tag, commit))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetRepoBranchAndTagCount(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/branch_tag_count repository repoBranchAndTagCountGet
|
||||||
|
// ---
|
||||||
|
// summary: Get branche and tag of a repository
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/RepoBranchAndTagCount"
|
||||||
|
|
||||||
|
tagsCountTotal, err := ctx.Repo.GitRepo.GetTagCount()
|
||||||
|
if err != nil {
|
||||||
|
ctx.Error(http.StatusInternalServerError, "GetTagCount", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
repo := ctx.Repo.Repository
|
||||||
|
branches, err := repo_module.GetBranches(repo)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GetBranches", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
result := api.RepoBranchAndTagCount{
|
||||||
|
BranchCount: len(branches),
|
||||||
|
TagCount: tagsCountTotal,
|
||||||
|
}
|
||||||
|
ctx.JSON(http.StatusOK, result)
|
||||||
|
}
|
||||||
|
|
|
@ -79,6 +79,13 @@ type swaggerResponseTag struct {
|
||||||
Body api.Tag `json:"body"`
|
Body api.Tag `json:"body"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RepoBranchAndTagCount
|
||||||
|
// swagger:response RepoBranchAndTagCount
|
||||||
|
type swaggerResponseRepoBranchAndTagCount struct {
|
||||||
|
// in:body
|
||||||
|
Body api.RepoBranchAndTagCount `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
// AnnotatedTag
|
// AnnotatedTag
|
||||||
// swagger:response AnnotatedTag
|
// swagger:response AnnotatedTag
|
||||||
type swaggerResponseAnnotatedTag struct {
|
type swaggerResponseAnnotatedTag struct {
|
||||||
|
|
|
@ -2363,6 +2363,39 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/repos/{owner}/{repo}/branch_tag_count": {
|
||||||
|
"get": {
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"repository"
|
||||||
|
],
|
||||||
|
"summary": "Get branche and tag of a repository",
|
||||||
|
"operationId": "repoBranchAndTagCountGet",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "owner of the repo",
|
||||||
|
"name": "owner",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "name of the repo",
|
||||||
|
"name": "repo",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"$ref": "#/responses/RepoBranchAndTagCount"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/repos/{owner}/{repo}/branches": {
|
"/repos/{owner}/{repo}/branches": {
|
||||||
"get": {
|
"get": {
|
||||||
"produces": [
|
"produces": [
|
||||||
|
@ -14679,6 +14712,11 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Body"
|
"x-go-name": "Body"
|
||||||
},
|
},
|
||||||
|
"changed_files": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"x-go-name": "ChangedFiles"
|
||||||
|
},
|
||||||
"closed_at": {
|
"closed_at": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "date-time",
|
"format": "date-time",
|
||||||
|
@ -14689,6 +14727,11 @@
|
||||||
"format": "int64",
|
"format": "int64",
|
||||||
"x-go-name": "Comments"
|
"x-go-name": "Comments"
|
||||||
},
|
},
|
||||||
|
"commit_num": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"x-go-name": "CommitNum"
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "date-time",
|
"format": "date-time",
|
||||||
|
@ -15033,6 +15076,23 @@
|
||||||
},
|
},
|
||||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||||
},
|
},
|
||||||
|
"RepoBranchAndTagCount": {
|
||||||
|
"description": "add",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"branch_count": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"x-go-name": "BranchCount"
|
||||||
|
},
|
||||||
|
"tag_count": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"x-go-name": "TagCount"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||||
|
},
|
||||||
"RepoCommit": {
|
"RepoCommit": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "RepoCommit contains information of a commit in the context of a repository.",
|
"title": "RepoCommit contains information of a commit in the context of a repository.",
|
||||||
|
@ -16399,6 +16459,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"RepoBranchAndTagCount": {
|
||||||
|
"description": "RepoBranchAndTagCount",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/RepoBranchAndTagCount"
|
||||||
|
}
|
||||||
|
},
|
||||||
"Repository": {
|
"Repository": {
|
||||||
"description": "Repository",
|
"description": "Repository",
|
||||||
"schema": {
|
"schema": {
|
||||||
|
|
Loading…
Reference in New Issue