Sort the tag before returning the list when calling API

Sort the tag before returning the list when calling API list tag API

Signed-off-by: Wenkai Yin <yinw@vmware.com>
This commit is contained in:
Wenkai Yin 2019-12-05 19:50:45 +08:00
parent 2fb1cc89d9
commit 4043ef8aa9

View File

@ -615,21 +615,24 @@ func (ra *RepositoryAPI) GetTags() {
}
tags = ts
}
result := []*models.TagResp{}
detail, err := ra.GetBool("detail", true)
if !detail && err == nil {
ra.Data["json"] = simpleTags(tags)
ra.ServeJSON()
return
}
ra.Data["json"] = assembleTagsInParallel(
result = simpleTags(tags)
} else {
result = assembleTagsInParallel(
client,
project.ProjectID,
repoName,
tags,
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()
}