Skip to content

[Proposal] add search interface for go-scm #146

Open
@colynn

Description

@colynn

we know go-scm can work well with Drone, and it can use repo.Find interface to find a specific project.

In our scenario, we hope can use string to search the project list, so whether we can add a search interface for go-scm,

interface

# https://github.com/go-atomci/go-scm/blob/master/scm/search.go#L16
	SearchService interface {
		// Find returns a repository by name.
		FindProjects(context.Context, string) ([]*Repository, *Response, error)
	}

gitlab sample

# gitlab
# https://github.com/go-atomci/go-scm/blob/master/scm/driver/gitlab/search.go#L18
func (s *searchService) FindProjects(ctx context.Context, projectName string) ([]*scm.Repository, *scm.Response, error) {
	path := fmt.Sprintf("api/v4/search?scope=projects&search=%s", encode(projectName))
	out := []*repository{}
	res, err := s.client.do(ctx, "GET", path, nil, &out)
	return convertRepositoryList(out), res, err
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions