Documentation
¶
Overview ¶
Package github provides functionality for interacting with the GitHub API.
It includes methods for authenticating with GitHub, retrieving repository information, checking if repositories are behind their upstream sources, and synchronizing repositories with their upstream sources.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapper around the GitHub API client that provides methods for interacting with GitHub repositories, particularly for synchronizing forked repositories with their upstream sources.
func NewClient ¶
NewClient creates a new GitHub client with the provided token. It authenticates with GitHub using the token and returns a Client that can be used to interact with the GitHub API.
func (*Client) GetForkedRepositories ¶
func (c *Client) GetForkedRepositories(ctx context.Context) ([]Repository, error)
GetForkedRepositories returns a list of repositories that are forks. It fetches all repositories for the authenticated user and filters out those that are not forks or don't have parent information.
func (*Client) IsRepositoryBehindUpstream ¶
func (c *Client) IsRepositoryBehindUpstream(ctx context.Context, repo Repository) (bool, int, error)
IsRepositoryBehindUpstream checks if a forked repository is behind its upstream. It compares the fork with its parent repository and returns whether the fork is behind, how many commits it's behind by, and any error encountered.
func (*Client) SyncRepositoryWithUpstream ¶
func (c *Client) SyncRepositoryWithUpstream(ctx context.Context, repo Repository) error
SyncRepositoryWithUpstream syncs a forked repository with its upstream. It attempts to merge changes from the upstream repository into the fork.
type Repository ¶
type Repository struct {
Owner string // Owner's username
Name string // Repository name
FullName string // Full repository name (owner/name)
ParentOwner string // Parent repository owner (for forks)
ParentName string // Parent repository name (for forks)
}
Repository represents a GitHub repository with information about its owner, name, and parent repository (for forks).