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) CreatePrivateRepo(ctx context.Context, org, name string) error
- func (c *GitHub) DeleteRepo(ctx context.Context, org, name 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 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) CreatePrivateRepo ¶
func (*GitHub) DeleteRepo ¶
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.