Documentation
¶
Index ¶
- Variables
- func ParseRepoURL(rawURL string) (domain, owner, repo string, err error)
- type ArchivedFilter
- type Client
- func (c *Client) FetchRepository(ctx context.Context, repoURL string) (*Repository, error)
- func (c *Client) FetchRepositoryFromPURL(ctx context.Context, p *purl.PURL) (*Repository, error)
- func (c *Client) FetchTags(ctx context.Context, repoURL string) ([]Tag, error)
- func (c *Client) FetchTagsFromPURL(ctx context.Context, p *purl.PURL) ([]Tag, error)
- func (c *Client) ForgeFor(domain string) (Forge, error)
- func (c *Client) ListRepositories(ctx context.Context, domain, owner string, opts ListOptions) ([]Repository, error)
- func (c *Client) RegisterDomain(ctx context.Context, domain, token string) error
- type Forge
- type ForgeType
- type ForkFilter
- type HTTPError
- type ListOptions
- type Option
- type Repository
- type Tag
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("repository not found")
ErrNotFound is returned when the requested repository does not exist.
var ErrOwnerNotFound = errors.New("owner not found")
ErrOwnerNotFound is returned when the requested owner (org or user) does not exist.
Functions ¶
func ParseRepoURL ¶
ParseRepoURL extracts the domain, owner, and repo from a repository URL. It handles https://, schemeless, and git@host:owner/repo SSH URLs, and strips .git suffixes and extra path segments.
Types ¶
type ArchivedFilter ¶ added in v0.1.1
type ArchivedFilter int
ArchivedFilter controls how archived repositories are handled in list operations.
const ( ArchivedInclude ArchivedFilter = iota ArchivedExclude ArchivedOnly )
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client routes requests to the appropriate Forge based on the URL domain.
func NewClient ¶
NewClient creates a Client with the default forge registrations and applies the given options.
func (*Client) FetchRepository ¶
FetchRepository fetches normalized repository metadata from a URL string.
func (*Client) FetchRepositoryFromPURL ¶
FetchRepositoryFromPURL fetches repository metadata using a PURL's repository_url qualifier.
func (*Client) FetchTagsFromPURL ¶
FetchTagsFromPURL fetches git tags using a PURL's repository_url qualifier.
func (*Client) ForgeFor ¶ added in v0.1.1
ForgeFor returns the Forge implementation registered for the given domain.
func (*Client) ListRepositories ¶ added in v0.1.1
func (c *Client) ListRepositories(ctx context.Context, domain, owner string, opts ListOptions) ([]Repository, error)
ListRepositories lists all repositories for an owner on the given domain.
type Forge ¶
type Forge interface {
FetchRepository(ctx context.Context, owner, repo string) (*Repository, error)
FetchTags(ctx context.Context, owner, repo string) ([]Tag, error)
ListRepositories(ctx context.Context, owner string, opts ListOptions) ([]Repository, error)
}
Forge is the interface each forge backend implements.
type ForkFilter ¶ added in v0.1.1
type ForkFilter int
ForkFilter controls how forked repositories are handled in list operations.
const ( ForkInclude ForkFilter = iota ForkExclude ForkOnly )
type ListOptions ¶ added in v0.1.1
type ListOptions struct {
Archived ArchivedFilter
Forks ForkFilter
PerPage int
}
ListOptions configures a ListRepositories call.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithGitLab ¶
WithGitLab registers a self-hosted GitLab instance.
func WithHTTPClient ¶
WithHTTPClient overrides the default HTTP client used by forge backends.
type Repository ¶
type Repository struct {
FullName string `json:"full_name"`
Owner string `json:"owner"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Homepage string `json:"homepage,omitempty"`
HTMLURL string `json:"html_url"`
Language string `json:"language,omitempty"`
License string `json:"license,omitempty"` // SPDX identifier
DefaultBranch string `json:"default_branch,omitempty"`
Fork bool `json:"fork"`
Archived bool `json:"archived"`
Private bool `json:"private"`
MirrorURL string `json:"mirror_url,omitempty"`
SourceName string `json:"source_name,omitempty"` // fork parent full name
Size int `json:"size"`
StargazersCount int `json:"stargazers_count"`
ForksCount int `json:"forks_count"`
OpenIssuesCount int `json:"open_issues_count"`
SubscribersCount int `json:"subscribers_count"`
HasIssues bool `json:"has_issues"`
PullRequestsEnabled bool `json:"pull_requests_enabled"`
Topics []string `json:"topics,omitempty"`
LogoURL string `json:"logo_url,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
PushedAt time.Time `json:"pushed_at,omitzero"`
}
Repository holds normalized metadata about a source code repository, independent of which forge hosts it.
func FilterRepos ¶ added in v0.1.1
func FilterRepos(repos []Repository, opts ListOptions) []Repository
FilterRepos applies archived and fork filters to a slice of repositories.