Documentation
¶
Overview ¶
Package github provides GitHub API integration for gh-stack.
internal/github/github.go
Index ¶
- Constants
- func CreatePR(head, base, title, body string) (int, error)
- func GenerateStackComment(root *tree.Node, currentBranch, trunk string) string
- func UpdatePRBase(number int, base string) error
- type Client
- func (c *Client) CreateComment(prNumber int, body string) (int, error)
- func (c *Client) CreateDraftPR(head, base, title, body string) (int, error)
- func (c *Client) CreateOrUpdateStackComment(prNumber int, body string) error
- func (c *Client) CreatePR(head, base, title, body string) (int, error)
- func (c *Client) FindStackComment(prNumber int) (int, error)
- func (c *Client) GetPR(number int) (*PR, error)
- func (c *Client) ListComments(prNumber int) ([]Comment, error)
- func (c *Client) MarkPRReady(prNumber int) error
- func (c *Client) UpdateComment(commentID int, body string) error
- func (c *Client) UpdatePRBase(number int, base string) error
- type Comment
- type PR
- type RESTClient
Constants ¶
const StackCommentMarker = "<!-- gh-stack:nav -->"
StackCommentMarker identifies gh-stack managed comments.
Variables ¶
This section is empty.
Functions ¶
func CreatePR ¶
CreatePR creates a new pull request using the default client. Deprecated: Use NewClient() and call methods directly for better error handling.
func GenerateStackComment ¶
GenerateStackComment builds markdown for a PR's stack position. It includes a warning if the PR targets a non-trunk branch.
func UpdatePRBase ¶
UpdatePRBase updates the base branch using the default client.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps a REST client with repo context.
func NewClientWithREST ¶
func NewClientWithREST(rest RESTClient, owner, repo string) *Client
NewClientWithREST creates a client with a custom REST implementation. This is primarily useful for testing.
func (*Client) CreateComment ¶
CreateComment adds a comment to a PR (PRs are issues in GitHub's API).
func (*Client) CreateDraftPR ¶
CreateDraftPR creates a new pull request as a draft.
func (*Client) CreateOrUpdateStackComment ¶
CreateOrUpdateStackComment finds an existing stack comment by marker and updates it, or creates a new one if none exists.
func (*Client) FindStackComment ¶
FindStackComment searches for an existing gh-stack comment on a PR. Returns the comment ID if found, or 0 if not found.
func (*Client) ListComments ¶
ListComments retrieves all comments on a PR.
func (*Client) MarkPRReady ¶
MarkPRReady converts a draft PR to ready for review. Uses the GraphQL API since REST doesn't support this operation.
func (*Client) UpdateComment ¶
UpdateComment updates an existing comment by ID.
type PR ¶
type PR struct {
Number int `json:"number"`
State string `json:"state"`
Merged bool `json:"merged"`
Draft bool `json:"draft"`
Base struct {
Ref string `json:"ref"`
} `json:"base"`
}
PR represents a GitHub pull request.
type RESTClient ¶
type RESTClient interface {
Get(path string, response any) error
Post(path string, body io.Reader, response any) error
Patch(path string, body io.Reader, response any) error
}
RESTClient defines the interface for GitHub REST API operations. The *api.RESTClient from go-gh satisfies this interface.