forked from Gitlink/gitea-1156
add:branch_tag_count
This commit is contained in:
parent
3e44c82aea
commit
b3399ea04d
|
@ -48,3 +48,8 @@ type CreateTagOption struct {
|
|||
Message string `json:"message"`
|
||||
Target string `json:"target"`
|
||||
}
|
||||
|
||||
type RepoBranchAndTagCount struct {
|
||||
BranchCount int `json:"branch_count"`
|
||||
TagCount int `json:"tag_count"`
|
||||
}
|
||||
|
|
|
@ -797,6 +797,10 @@ func Routes() *web.Route {
|
|||
m.Get("/*", repo.GetReadmeContentsByPath)
|
||||
})
|
||||
m.Get("/commits_slice", repo.GetAllCommitsSliceByTime)
|
||||
// m.Get("/branchtagcount", repo.BranchTagCount)
|
||||
m.Group("/branch_tag_count", func() {
|
||||
m.Get("", repo.BranchTagCount)
|
||||
}, reqRepoReader(models.UnitTypeCode), context.ReferencesGitRepo(true))
|
||||
m.Group("/tags", func() {
|
||||
m.Get("", repo.ListTags)
|
||||
m.Get("/*", repo.GetTag)
|
||||
|
|
|
@ -133,7 +133,7 @@ func ListPullRequests(ctx *context.APIContext) {
|
|||
func GetPullRequest(ctx *context.APIContext) {
|
||||
// swagger:operation GET /repos/{owner}/{repo}/pulls/{index} repository repoGetPullRequest
|
||||
// ---
|
||||
// summary: Get a pull request
|
||||
// summary: Get a pull request ***
|
||||
// produces:
|
||||
// - application/json
|
||||
// parameters:
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
repo_module "code.gitea.io/gitea/modules/repository"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/routers/api/v1/utils"
|
||||
|
@ -277,3 +278,42 @@ func DeleteTag(ctx *context.APIContext) {
|
|||
|
||||
ctx.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
func BranchTagCount(ctx *context.APIContext) {
|
||||
// swagger:operation GET /repos/{owner}/{repo}/branch_tag_count repository repoBranchTagCount
|
||||
// ---
|
||||
// summary: List a repository's tags***
|
||||
// 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"
|
||||
|
||||
tags, err := ctx.Repo.GitRepo.GetTagInfos(0, 0) // tags info
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetTags", err)
|
||||
return
|
||||
}
|
||||
repo := ctx.Repo.Repository
|
||||
_, countAll, err := repo_module.GetBranches(repo, -1, -1) //get count of the branch
|
||||
if err != nil {
|
||||
ctx.ServerError("GetBranches", err)
|
||||
return
|
||||
}
|
||||
result := api.RepoBranchAndTagCount{
|
||||
BranchCount: countAll,
|
||||
TagCount: len(tags),
|
||||
}
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
|
|
@ -64,6 +64,12 @@ type swaggerResponseWikiList struct {
|
|||
Body api.WikiesResponse `json:"body"`
|
||||
}
|
||||
|
||||
// RepoBranchAndTagCount
|
||||
// swagger:response RepoBranchAndTagCount
|
||||
type swaggerResponseRepoBranchAndTagCount struct {
|
||||
Body api.RepoBranchAndTagCount `json:"body"`
|
||||
}
|
||||
|
||||
// TagList
|
||||
// swagger:response TagList
|
||||
type swaggerResponseTagList struct {
|
||||
|
|
|
@ -2539,8 +2539,8 @@
|
|||
"tags": [
|
||||
"repository"
|
||||
],
|
||||
"summary": "Get branche and tag of a repository",
|
||||
"operationId": "repoBranchAndTagCountGet",
|
||||
"summary": "List a repository's tags***",
|
||||
"operationId": "repoBranchTagCount",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
|
@ -7271,7 +7271,7 @@
|
|||
"tags": [
|
||||
"repository"
|
||||
],
|
||||
"summary": "Get a pull request",
|
||||
"summary": "Get a pull request ***",
|
||||
"operationId": "repoGetPullRequest",
|
||||
"parameters": [
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue