Documentation
¶
Index ¶
- Variables
- func ParseRepoURL(rawURL string) (domain, owner, repo string, err error)
- 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) RegisterDomain(ctx context.Context, domain, token string) error
- type Forge
- type ForgeType
- type HTTPError
- 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.
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 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.
type Forge ¶
type Forge interface {
FetchRepository(ctx context.Context, owner, repo string) (*Repository, error)
FetchTags(ctx context.Context, owner, repo string) ([]Tag, error)
}
Forge is the interface each forge backend implements.
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.