Merge pull request #10164 from ywk253100/191205_sort

Sort the tag before returning the list when calling API
This commit is contained in:
Wang Yan 2019-12-06 11:38:31 +08:00 committed by GitHub
commit 9e83b9f1fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -615,21 +615,24 @@ func (ra *RepositoryAPI) GetTags() {
} }
tags = ts tags = ts
} }
result := []*models.TagResp{}
detail, err := ra.GetBool("detail", true) detail, err := ra.GetBool("detail", true)
if !detail && err == nil { if !detail && err == nil {
ra.Data["json"] = simpleTags(tags) result = simpleTags(tags)
ra.ServeJSON() } else {
return result = assembleTagsInParallel(
}
ra.Data["json"] = assembleTagsInParallel(
client, client,
project.ProjectID, project.ProjectID,
repoName, repoName,
tags, tags,
ra.SecurityCtx.GetUsername(), ra.SecurityCtx.GetUsername(),
) )
}
// sort by tag name
sort.Slice(result, func(i, j int) bool {
return result[i].Name < result[j].Name
})
ra.Data["json"] = result
ra.ServeJSON() ra.ServeJSON()
} }