Documentation
¶
Overview ¶
Package git is the seam to the service that hosts platform repositories and pull requests.
Index ¶
- Constants
- func GitHubTokenFromCLI() (string, error)
- func MissingScopes(header string, present bool) []string
- type GitHub
- func (c *GitHub) CloneURL(org, name string) string
- func (c *GitHub) CreateIssueComment(ctx context.Context, owner, repo string, number int, body string) error
- func (c *GitHub) CreatePrivateRepo(ctx context.Context, org, name string) error
- func (c *GitHub) DeleteIssueComment(ctx context.Context, owner, repo string, id int64) error
- func (c *GitHub) DeleteRepo(ctx context.Context, org, name string) error
- func (c *GitHub) EditIssueComment(ctx context.Context, owner, repo string, id int64, body string) error
- func (c *GitHub) IssueComments(ctx context.Context, owner, repo string, number int) ([]IssueComment, error)
- func (c *GitHub) Login(ctx context.Context) (string, error)
- func (c *GitHub) OpenPullRequest(ctx context.Context, owner, repo, head, base, title, body string) (string, error)
- func (c *GitHub) Orgs(ctx context.Context) ([]string, error)
- func (c *GitHub) ReleaseTags(ctx context.Context, owner, repo string) ([]string, error)
- func (c *GitHub) RepoState(ctx context.Context, org, name string) (RepoState, error)
- func (c *GitHub) Token() string
- func (c *GitHub) Validate(ctx context.Context) (string, error)
- type Host
- type IssueComment
- type RepoState
Constants ¶
const GitHubName = "github"
GitHubName names the GitHub Host, as saved on an Installation.
const GitHubPATHelp = `` /* 813-byte string literal not displayed */
GitHubPATHelp explains the token a user needs when the gh CLI is unavailable.
Variables ¶
This section is empty.
Functions ¶
func GitHubTokenFromCLI ¶
GitHubTokenFromCLI returns the token of an authenticated gh CLI, or an error if gh is missing or logged out.
func MissingScopes ¶
MissingScopes checks a classic token's X-OAuth-Scopes header. present=false means a fine-grained token.
Types ¶
type GitHub ¶
type GitHub struct {
// contains filtered or unexported fields
}
GitHub is the Host adapter for github.com.
func (*GitHub) CreateIssueComment ¶ added in v0.1.5
func (c *GitHub) CreateIssueComment(ctx context.Context, owner, repo string, number int, body string) error
CreateIssueComment adds a comment to an issue or pull request.
func (*GitHub) CreatePrivateRepo ¶
func (*GitHub) DeleteIssueComment ¶ added in v0.1.5
DeleteIssueComment deletes a comment.
func (*GitHub) DeleteRepo ¶
func (*GitHub) EditIssueComment ¶ added in v0.1.5
func (c *GitHub) EditIssueComment(ctx context.Context, owner, repo string, id int64, body string) error
EditIssueComment replaces the body of a comment.
func (*GitHub) IssueComments ¶ added in v0.1.5
func (c *GitHub) IssueComments(ctx context.Context, owner, repo string, number int) ([]IssueComment, error)
IssueComments lists all comments of an issue or pull request, oldest first.
func (*GitHub) Login ¶ added in v0.1.5
Login returns the login of the token's owner. Unlike Validate it checks no scopes, so it works for any token that may read the user (GitHub Actions' GITHUB_TOKEN may not).
func (*GitHub) OpenPullRequest ¶
func (c *GitHub) OpenPullRequest(ctx context.Context, owner, repo, head, base, title, body string) (string, error)
OpenPullRequest creates a PR from head into base, or returns the URL of the one already open.
func (*GitHub) ReleaseTags ¶
ReleaseTags lists the release tags (vX.Y.Z) of owner/repo, newest first.
type Host ¶
type Host interface {
// Validate checks the token and returns the login it belongs to.
Validate(ctx context.Context) (login string, err error)
// Token is the credential used to push to platform repositories.
Token() string
// Orgs lists the organizations a platform repository can be created in.
Orgs(ctx context.Context) ([]string, error)
RepoState(ctx context.Context, org, name string) (RepoState, error)
CreatePrivateRepo(ctx context.Context, org, name string) error
DeleteRepo(ctx context.Context, org, name string) error
CloneURL(org, name string) string
// OpenPullRequest creates a PR from head into base, or updates and returns the one already open.
OpenPullRequest(ctx context.Context, owner, repo, head, base, title, body string) (url string, err error)
}
Host is a git hosting service. GitHub is the only adapter today; the gittest fake is the second.
type IssueComment ¶ added in v0.1.5
IssueComment is a comment on an issue or pull request.