commit
e35ced12e7
|
@ -53,3 +53,7 @@ type RepoBranchAndTagCount struct {
|
|||
BranchCount int `json:"branch_count"`
|
||||
TagCount int `json:"tag_count"`
|
||||
}
|
||||
|
||||
type BranchNameSet struct {
|
||||
BranchName []*string `json:"branch_name"`
|
||||
}
|
||||
|
|
|
@ -839,7 +839,7 @@ func Routes() *web.Route {
|
|||
m.Get("/*", repo.GetReadmeContentsByPath)
|
||||
})
|
||||
m.Get("/commits_slice", repo.GetAllCommitsSliceByTime)
|
||||
// m.Get("/branchtagcount", repo.BranchTagCount)
|
||||
m.Get("/branch_name_set", repo.BranchNameSet)
|
||||
m.Group("/branch_tag_count", func() {
|
||||
m.Get("", repo.BranchTagCount)
|
||||
}, reqRepoReader(models.UnitTypeCode), context.ReferencesGitRepo(true))
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
repo_module "code.gitea.io/gitea/modules/repository"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
|
@ -306,7 +307,7 @@ func BranchTagCount(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
repo := ctx.Repo.Repository
|
||||
_, countAll, err := repo_module.GetBranches(repo, -1, -1) //get count of the branch
|
||||
_, countAll, err := repo_module.GetBranches(repo, 0, 0) //get count of the branch
|
||||
if err != nil {
|
||||
ctx.ServerError("GetBranches", err)
|
||||
return
|
||||
|
@ -317,3 +318,49 @@ func BranchTagCount(ctx *context.APIContext) {
|
|||
}
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func BranchNameSet(ctx *context.APIContext) {
|
||||
// swagger:operation GET /repos/{owner}/{repo}/branch_name_set repository repoBranchNameSet
|
||||
// ---
|
||||
// summary: List a repository's branch name***
|
||||
// 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/BranchNameSet"
|
||||
|
||||
repo := ctx.Repo.Repository
|
||||
branches, _, err := repo_module.GetBranches(repo, 0, 0) //get count of the branch
|
||||
if err != nil {
|
||||
ctx.ServerError("GetBranches", err)
|
||||
return
|
||||
}
|
||||
|
||||
var branchNameSet = make([]*string, 0)
|
||||
|
||||
// var branchNameSet [len(branches)]string
|
||||
for _, branch := range branches {
|
||||
|
||||
log.Info("branches is \n", branch.Name)
|
||||
branchNameSet = append(branchNameSet, &branch.Name)
|
||||
|
||||
}
|
||||
|
||||
result := api.BranchNameSet{
|
||||
BranchName: branchNameSet,
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
|
||||
}
|
||||
|
|
|
@ -72,6 +72,12 @@ type swaggerResponseRepoBranchAndTagCount struct {
|
|||
Body api.RepoBranchAndTagCount `json:"body"`
|
||||
}
|
||||
|
||||
// BranchNameSet
|
||||
// swagger:response BranchNameSet
|
||||
type swaggerResponseBranchNameSet struct {
|
||||
Body api.BranchNameSet `json:"body"`
|
||||
}
|
||||
|
||||
// TagList
|
||||
// swagger:response TagList
|
||||
type swaggerResponseTagList struct {
|
||||
|
|
|
@ -2424,6 +2424,39 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/branch_name_set": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"repository"
|
||||
],
|
||||
"summary": "List a repository's branch name***",
|
||||
"operationId": "repoBranchNameSet",
|
||||
"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/BranchNameSet"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/branch_protections": {
|
||||
"get": {
|
||||
"produces": [
|
||||
|
@ -13037,6 +13070,19 @@
|
|||
},
|
||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||
},
|
||||
"BranchNameSet": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"branch_name": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"x-go-name": "BranchName"
|
||||
}
|
||||
},
|
||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||
},
|
||||
"BranchProtection": {
|
||||
"description": "BranchProtection represents a branch protection for a repository",
|
||||
"type": "object",
|
||||
|
@ -18331,6 +18377,15 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"BranchNameSet": {
|
||||
"description": "BranchNameSet",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/BranchNameSet"
|
||||
},
|
||||
"headers": {
|
||||
"body": {}
|
||||
}
|
||||
},
|
||||
"BranchProtection": {
|
||||
"description": "BranchProtection",
|
||||
"schema": {
|
||||
|
|
Loading…
Reference in New Issue