github

package
v1.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneURL

func CloneURL(host, owner, repo, token string) string

CloneURL returns the HTTPS clone URL for a repository.

func IsRateLimitError

func IsRateLimitError(err error) bool

IsRateLimitError returns true if the error is a GitHub rate limit error (primary or secondary/abuse). Callers can use this to skip operations rather than retrying when rate limits are exhausted.

func RetryAfterFromError

func RetryAfterFromError(err error) time.Duration

RetryAfterFromError extracts the retry-after duration from a GitHub AbuseRateLimitError. Returns 0 if the error is not an abuse rate limit error or has no RetryAfter set.

Types

type Client

type Client struct {
	API  *gh.Client
	Host string
	// contains filtered or unexported fields
}

Client wraps the GitHub API client for both Cloud and Enterprise.

func NewClient

func NewClient(host, token string) (*Client, error)

NewClient creates a GitHub API client for the given host and token. If token is empty, an unauthenticated client is created (suitable for public repos). All clients automatically handle rate limiting by sleeping until reset.

func (*Client) CreateIssue

func (c *Client) CreateIssue(owner, repo string, req *gh.IssueRequest) (*gh.Issue, error)

CreateIssue creates an issue in the target repository.

func (*Client) CreateIssueComment

func (c *Client) CreateIssueComment(owner, repo string, number int, body string) error

CreateIssueComment creates a comment on an issue.

func (*Client) CreateLabel

func (c *Client) CreateLabel(owner, repo string, label *gh.Label) error

CreateLabel creates a label in the target repository.

func (*Client) CreateRelease

func (c *Client) CreateRelease(owner, repo string, release *gh.RepositoryRelease) (*gh.RepositoryRelease, error)

CreateRelease creates a release in the target repository.

func (*Client) CreateRepo

func (c *Client) CreateRepo(org, name, visibility string, verbose bool) error

CreateRepo creates a repository in the specified organization or user account. It first tries the org endpoint; if the target is a personal account (404), it falls back to creating under the authenticated user.

func (*Client) DeleteRelease

func (c *Client) DeleteRelease(owner, repo string, releaseID int64) error

DeleteRelease deletes a release by its ID. Does not delete the associated tag.

func (*Client) DownloadReleaseAsset

func (c *Client) DownloadReleaseAsset(owner, repo string, assetID int64) (*http.Response, error)

DownloadReleaseAsset downloads a release asset and returns the HTTP response body. Caller is responsible for closing the response body.

func (*Client) EditIssue

func (c *Client) EditIssue(owner, repo string, number int, req *gh.IssueRequest) error

EditIssue updates an existing issue (e.g. to close it).

func (*Client) ListAllIssues

func (c *Client) ListAllIssues(owner, repo string) ([]*gh.Issue, error)

ListAllIssues returns all issues (not PRs) for a repository.

func (*Client) ListIssueComments

func (c *Client) ListIssueComments(owner, repo string, number int) ([]*gh.IssueComment, error)

ListIssueComments returns all comments on an issue.

func (*Client) ListLabels

func (c *Client) ListLabels(owner, repo string) ([]*gh.Label, error)

ListLabels returns all labels for a repository.

func (*Client) ListPullRequests

func (c *Client) ListPullRequests(owner, repo string) ([]*gh.PullRequest, error)

ListPullRequests returns all pull requests for a repository.

func (*Client) ListReleaseAssets

func (c *Client) ListReleaseAssets(owner, repo string, releaseID int64) ([]*gh.ReleaseAsset, error)

ListReleaseAssets returns all assets for a release.

func (*Client) ListReleases

func (c *Client) ListReleases(owner, repo string) ([]*gh.RepositoryRelease, error)

ListReleases returns all releases for a repository.

func (*Client) RepoExists

func (c *Client) RepoExists(owner, repo string) (bool, error)

RepoExists checks whether a repository exists and is accessible.

func (*Client) SearchRepos

func (c *Client) SearchRepos(org, nameFilter string) ([]string, error)

SearchRepos finds repositories in a given org whose names contain the query string. Returns a list of repo names (not full names — just the repo part).

func (*Client) UploadReleaseAsset

func (c *Client) UploadReleaseAsset(owner, repo string, releaseID int64, name string, file *UploadFile) error

UploadReleaseAsset uploads an asset to a release.

type UploadFile

type UploadFile struct {
	*os.File
}

UploadFile wraps an io.Reader into a temporary *os.File for the GitHub API.

func NewUploadFile

func NewUploadFile(r io.Reader, name string, size int64) (*UploadFile, error)

NewUploadFile creates a temp file from a reader for upload.

func (*UploadFile) Cleanup

func (f *UploadFile) Cleanup()

Cleanup removes the temporary file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL