新增:仓库标签详情接口

This commit is contained in:
yystopf 2023-12-11 08:49:56 +08:00
parent c4829333a8
commit cc050e9c19
2 changed files with 15 additions and 0 deletions

View File

@ -79,6 +79,7 @@ func Routers(ctx gocontext.Context) *web.Route {
}, context.ReferencesGitRepo(), reqRepoReader(unit.TypeCode))
m.Group("/tags", func() {
m.Get("", repo.ListTags)
m.Get("/*", repo.GetTag)
}, reqRepoReader(unit_model.TypeCode), context.ReferencesGitRepo(true))
m.Group("/wikies", func() {
m.Combo("").Get(repo.ListWikiPages).

View File

@ -44,6 +44,20 @@ func ListTags(ctx *context.APIContext) {
ctx.JSON(http.StatusOK, &apiTags)
}
func GetTag(ctx *context.APIContext) {
tagName := ctx.Params("*")
tag, err := ctx.Repo.GitRepo.GetTag(tagName)
if err != nil {
ctx.NotFound(tagName)
}
apiTag, err := convert.ToTag(ctx.Repo.Repository, ctx.Repo.GitRepo, tag)
if err != nil {
ctx.Error(http.StatusInternalServerError, "hat_convert.ToTag", err)
}
ctx.JSON(http.StatusOK, apiTag)
}
func BranchTagCount(ctx *context.APIContext) {
_, tagsTotal, err := ctx.Repo.GitRepo.GetTagInfos(0, 0)
if err != nil {