{"modulePath":"github.com/giantswarm/gitops-commit","version":"v0.14.0-rc.9","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package github\n\n## Types\n\n```go\ntype Option = gogithub.ClientOptionsFunc\n```\nOption configures New.\n\n```go\nfunc WithBaseURL(baseURL string) Option\n```\nWithBaseURL points the client at another API root: a GitHub Enterprise Server, or a test server.\n\n```go\nfunc WithHTTPClient(c *http.Client) Option\n```\nWithHTTPClient sets the HTTP client the requests go through.\n\n```go\ntype Remote struct {\n\t// contains filtered or unexported fields\n}\n```\nRemote is the Remote for github.com (or a GitHub Enterprise Server) acting with the token the caller supplies. It talks REST through google/go-github, never a git or sops binary.\n\n```go\nfunc New(token string, opts ...Option) (*Remote, error)\n```\nNew builds the Remote from the caller's token. The token is the caller's; the module keeps none of its own.\n\n```go\nfunc NewWithClient(hc *http.Client, opts ...Option) (*Remote, error)\n```\nNewWithClient builds the Remote on an HTTP client that already carries the caller's identity — a GitHub App installation transport, a rotated token file — so no token string changes hands. The module adds no credential of its own to it.\n\n```go\nfunc (g *Remote) Approve(ctx context.Context, pr forge.PullRequest, body string) error\n```\nApprove submits an approving review on the pull request with the caller's identity, pinned to pr.HeadSHA when the caller names it. GitHub applies its own rules to the call: the author of a pull request cannot approve it.\n\n```go\nfunc (g *Remote) CanReadRepository(ctx context.Context, repo forge.Repository) (bool, error)\n```\nCanReadRepository implements forge.RepositoryAccess with GET /repos/{owner}/{repo}: 404 is false, a refused token an AuthError.\n\n```go\nfunc (g *Remote) Close(ctx context.Context, pr forge.PullRequest, deleteBranch bool) error\n```\nClose closes the pull request and, when asked, deletes its head branch. A pull request that is closed already (merged or not) is left as it is.\n\n```go\nfunc (g *Remote) Commit(ctx context.Context, repo forge.Repository, branch, message string, files map[string][]byte) error\n```\nCommit writes one commit with files on top of branch: blobs, a tree on the head's tree, the commit, and a fast-forward of the branch. A nil content removes the path from the tree.\n\n```go\nfunc (g *Remote) CreateBranch(ctx context.Context, repo forge.Repository, branch, base string) error\n```\nCreateBranch creates branch at base's head. An existing branch (GitHub answers 422 to the create) is brought up to date with base instead.\n\n```go\nfunc (g *Remote) EnableAutoMerge(ctx context.Context, pr forge.PullRequest) error\n```\nEnableAutoMerge arms GitHub's auto-merge on the pull request with the repository's merge method. Auto-merge is GraphQL-only; the mutation goes through the same client and identity as every other call.\n\n```go\nfunc (g *Remote) FindPullRequest(ctx context.Context, repo forge.Repository, head string) (forge.PullRequest, bool, error)\n```\nFindPullRequest returns the open pull request of head, if there is one.\n\n```go\nfunc (g *Remote) FindPullRequestsByPrefix(ctx context.Context, repo forge.Repository, prefix string) ([]forge.PullRequest, error)\n```\nFindPullRequestsByPrefix lists the repository's open pull requests page by page and keeps those whose head branch starts with prefix and lives in the repository itself: GitHub's head filter takes an exact branch name only. The head is the repository's own when its repository ID is the base's; a fork's pull request, or one whose fork was deleted, is left out. The pages are read oldest first, so a pull request opened during the read goes to the last page and shifts none of the pages still to read.\n\n```go\nfunc (g *Remote) Head(ctx context.Context, repo forge.Repository, branch string) (string, error)\n```\nHead returns the SHA of the commit at the head of branch, from the branch's ref.\n\n```go\nfunc (g *Remote) ListFiles(ctx context.Context, repo forge.Repository, ref, dir string) ([]string, error)\n```\nListFiles returns the files under dir at ref — a branch's head or a commit — from its recursive Git tree. A tree GitHub truncates is an error, never a partial answer. A commit SHA GitHub does not find is ErrFileNotFound; a missing branch stays the error GitHub answers.\n\n```go\nfunc (g *Remote) Merge(ctx context.Context, pr forge.PullRequest) error\n```\nMerge merges the pull request with the repository's merge method (squash where allowed, else merge commit, else rebase), only if the head is still pr.HeadSHA. GitHub applies its own protection rules to the call.\n\n```go\nfunc (g *Remote) MergedFiles(ctx context.Context, pr forge.PullRequest) ([]forge.FileChange, error)\n```\nMergedFiles lists the merged pull request's files through GitHub's pull request files endpoint, page by page. GitHub lists at most 3000 files; a listing shorter than the pull request's changed-file count is an error, never a partial answer.\n\n```go\nfunc (g *Remote) OpenDraftPullRequest(ctx context.Context, repo forge.Repository, head, base, title, body string) (forge.PullRequest, error)\n```\nOpenDraftPullRequest is OpenPullRequest as a draft.\n\n```go\nfunc (g *Remote) OpenPullRequest(ctx context.Context, repo forge.Repository, head, base, title, body string) (forge.PullRequest, error)\n```\nOpenPullRequest opens head against base with the caller's title and body. When head already has an open pull request, that one is returned.\n\n```go\nfunc (g *Remote) ReadFile(ctx context.Context, repo forge.Repository, ref, path string) ([]byte, error)\n```\nReadFile returns the content of path at ref — a branch's head or a commit — through the Git blob so a file past the contents API's 1 MB inline limit reads whole. GitHub answers 404 for a missing path and for a missing commit alike.\n\n```go\nfunc (g *Remote) Revert(ctx context.Context, pr forge.PullRequest, body string, overrides map[string][]byte) (forge.PullRequest, error)\n```\nRevert opens a pull request undoing the merged pr: the merge commit's diff against its first parent, inverted into one commit on branch revert-\\\u003cnumber\u003e-\\\u003chead\u003e. The branch is brought into existence or up to date with the pull request's base the way CreateBranch does — ErrStaleBranch when the base does not merge into it — and the commit lands on its head, so a second revert adds a commit to the open revert pull request.\n\n```go\nfunc (g *Remote) Status(ctx context.Context, pr forge.PullRequest) (forge.Status, error)\n```\nStatus reads the pull request, its reviews, and the statuses and check runs of its head.\n\n","path":"github.com/giantswarm/gitops-commit/forge/github","name":"github","synopsis":"","isRedistributable":true}
