{"modulePath":"github.com/boneskull/gh-stack","version":"v1.3.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package github\n\nPackage github provides GitHub API integration for gh-stack.\n\ninternal/github/github.go\n\n## Constants\n\n```go\nconst StackCommentMarker = \"\u003c!-- gh-stack:nav --\u003e\"\n```\nStackCommentMarker identifies gh-stack managed comments.\n\n## Functions\n\n```go\nfunc CollectPRNumbers(root *tree.Node) []int\n```\nCollectPRNumbers walks a tree and returns all PR numbers found.\n\n```go\nfunc CreatePR(head, base, title, body string) (int, error)\n```\nCreatePR creates a new pull request using the default client.\n\nDeprecated: Use NewClient() and call methods directly for better error handling.\n\n```go\nfunc GenerateStackComment(root *tree.Node, currentBranch, trunk, repoURL string, prInfo map[int]PRInfo, remoteBranches map[string]bool) string\n```\nGenerateStackComment builds markdown for a PR's stack position. It includes a warning if the PR targets a non-trunk branch. The repoURL should be the base repository URL (e.g., \"[https://github.com/owner/repo](https://github.com/owner/repo)\"). The prInfo map provides titles for PRs (keyed by PR number).\n\nOnly the current stack is rendered: the path from root to the current branch, plus all descendants of the current branch. Sibling stacks are excluded.\n\nIf remoteBranches is non-nil, branches without PRs that don't exist on the remote are omitted (their children are promoted up a level). Pass nil to disable this filtering.\n\n```go\nfunc UpdatePRBase(number int, base string) error\n```\nUpdatePRBase updates the base branch using the default client.\n\n## Types\n\n```go\ntype Client struct {\n\t// contains filtered or unexported fields\n}\n```\nClient wraps a REST client with repo context.\n\n```go\nfunc NewClient() (*Client, error)\n```\nNewClient creates a new GitHub client for the current repository.\n\n```go\nfunc NewClientWithREST(rest RESTClient, owner, repo string) *Client\n```\nNewClientWithREST creates a client with a custom REST implementation. This is primarily useful for testing.\n\n```go\nfunc (c *Client) CreateComment(prNumber int, body string) (int, error)\n```\nCreateComment adds a comment to a PR (PRs are issues in GitHub's API).\n\n```go\nfunc (c *Client) CreateDraftPR(head, base, title, body string) (int, error)\n```\nCreateDraftPR creates a new pull request as a draft.\n\n```go\nfunc (c *Client) CreateOrUpdateStackComment(prNumber int, body string) error\n```\nCreateOrUpdateStackComment finds an existing stack comment by marker and updates it, or creates a new one if none exists. Skips the update if the body hasn't changed.\n\n```go\nfunc (c *Client) CreatePR(head, base, title, body string) (int, error)\n```\nCreatePR creates a new pull request and returns the PR number.\n\n```go\nfunc (c *Client) CreateSubmitPR(head, base, title, body string, draft bool) (*PR, error)\n```\nCreateSubmitPR creates a new pull request. This is the primary method for the submit workflow. If draft is true, creates a draft PR. The body parameter is used as the PR description; pass an empty string for no description.\n\n```go\nfunc (c *Client) FindPRByHead(branch string) (*PR, error)\n```\nFindPRByHead finds an open PR with the given head branch. Returns nil, nil if no PR exists for this branch.\n\n```go\nfunc (c *Client) FindStackComment(prNumber int) (int, string, error)\n```\nFindStackComment searches for an existing gh-stack comment on a PR. Returns the comment ID and body if found, or (0, \"\") if not found.\n\n```go\nfunc (c *Client) GenerateAndPostStackComment(root *tree.Node, branch, trunk string, prNumber int, remoteBranches map[string]bool) error\n```\nGenerateAndPostStackComment generates and posts/updates a stack comment for a PR. It fetches PR titles via GraphQL and renders the full comment.\n\nIf remoteBranches is non-nil, branches without PRs that don't exist on the remote are omitted from the rendered comment. Pass nil to disable filtering.\n\n```go\nfunc (c *Client) GetPR(number int) (*PR, error)\n```\nGetPR fetches PR details by number.\n\n```go\nfunc (c *Client) GetPRTitles(prNumbers []int) (map[int]PRInfo, error)\n```\nGetPRTitles fetches titles for multiple PRs in a single GraphQL request. Returns a map of PR number to PRInfo. PRs that don't exist are omitted.\n\nNote: This builds a single GraphQL query with all PR requests. For extremely large stacks (100+ PRs), this could potentially hit query size limits. In practice, stacks rarely exceed 10-20 PRs, so batching is not implemented.\n\n```go\nfunc (c *Client) ListComments(prNumber int) ([]Comment, error)\n```\nListComments retrieves all comments on a PR.\n\n```go\nfunc (c *Client) MarkPRReady(prNumber int) error\n```\nMarkPRReady converts a draft PR to ready for review. Uses the GraphQL API since REST doesn't support this operation.\n\n```go\nfunc (c *Client) PRURL(number int) string\n```\nPRURL returns the web URL for a pull request.\n\n```go\nfunc (c *Client) RepoURL() string\n```\nRepoURL returns the base URL for the repository (e.g., \"[https://github.com/owner/repo](https://github.com/owner/repo)\").\n\n```go\nfunc (c *Client) UpdateComment(commentID int, body string) error\n```\nUpdateComment updates an existing comment by ID.\n\n```go\nfunc (c *Client) UpdatePRBase(number int, base string) error\n```\nUpdatePRBase updates the base branch of a PR.\n\n```go\ntype Comment struct {\n\tID   int    `json:\"id\"`\n\tBody string `json:\"body\"`\n}\n```\nComment represents a GitHub issue/PR comment.\n\n```go\ntype PR struct {\n\tNumber int    `json:\"number\"`\n\tTitle  string `json:\"title\"`\n\tState  string `json:\"state\"`\n\tMerged bool   `json:\"merged\"`\n\tDraft  bool   `json:\"draft\"`\n\tBase   struct {\n\t\tRef string `json:\"ref\"`\n\t} `json:\"base\"`\n}\n```\nPR represents a GitHub pull request.\n\n```go\nfunc GetPR(number int) (*PR, error)\n```\nGetPR fetches PR details using the default client.\n\n```go\ntype PRInfo struct {\n\tNumber int\n\tTitle  string\n}\n```\nPRInfo contains display information for a PR in stack comments.\n\n```go\ntype RESTClient interface {\n\tGet(path string, response any) error\n\tPost(path string, body io.Reader, response any) error\n\tPatch(path string, body io.Reader, response any) error\n}\n```\nRESTClient defines the interface for GitHub REST API operations. The \\*api.RESTClient from go-gh satisfies this interface.\n\n","path":"github.com/boneskull/gh-stack/internal/github","name":"github","synopsis":"Package github provides GitHub API integration for gh-stack.","isRedistributable":true}
