示例#1
0
//getTotalRepoCount returns total repo count
func getTotalRepoCount() int {
	repoList, err := svc_utils.GetRepoFromCache()
	if err != nil {
		log.Errorf("Failed to get repo from cache, error: %v", err)
		return 0
	}
	return len(repoList)

}
示例#2
0
//getReposByProject returns repo numbers of specified project
func getRepoCountByProject(projectName string) int {
	repoList, err := svc_utils.GetRepoFromCache()
	if err != nil {
		log.Errorf("Failed to get repo from cache, error: %v", err)
		return 0
	}
	var resp int
	if len(projectName) > 0 {
		for _, r := range repoList {
			if strings.Contains(r, "/") && r[0:strings.LastIndex(r, "/")] == projectName {
				resp++
			}
		}
		return resp
	}
	return 0
}