コード例 #1
0
ファイル: gitlab.go プロジェクト: Ablu/drone
// Repos fetches a list of repos from the remote system.
func (g *Gitlab) Repos(u *model.User) ([]*model.RepoLite, error) {
	client := NewClient(g.URL, u.Token, g.SkipVerify)

	var repos = []*model.RepoLite{}

	all, err := client.AllProjects(g.HideArchives)
	if err != nil {
		return repos, err
	}

	for _, repo := range all {
		var parts = strings.Split(repo.PathWithNamespace, "/")
		var owner = parts[0]
		var name = parts[1]
		var avatar = repo.AvatarUrl

		if len(avatar) != 0 && !strings.HasPrefix(avatar, "http") {
			avatar = fmt.Sprintf("%s/%s", g.URL, avatar)
		}

		repos = append(repos, &model.RepoLite{
			Owner:    owner,
			Name:     name,
			FullName: repo.PathWithNamespace,
			Avatar:   avatar,
		})
	}

	return repos, err
}
コード例 #2
0
ファイル: gitlab.go プロジェクト: brancusi/drone
// Repos fetches a list of repos from the remote system.
func (g *Gitlab) Repos(u *model.User) ([]*model.RepoLite, error) {
	client := NewClient(g.URL, u.Token, g.SkipVerify)

	var repos = []*model.RepoLite{}

	all, err := client.AllProjects()
	if err != nil {
		return repos, err
	}

	for _, repo := range all {
		var parts = strings.Split(repo.PathWithNamespace, "/")
		var owner = parts[0]
		var name = parts[1]

		repos = append(repos, &model.RepoLite{
			Owner:    owner,
			Name:     name,
			FullName: repo.PathWithNamespace,
		})

		// TODO: add repo.AvatarUrl
	}
	return repos, err
}