github

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPRReview

func BuildPRReview(results []markdown.FileResult, event, body string) *gh.PullRequestReviewRequest

BuildPRReview builds a GitHub PR review request from file review results.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps the go-github client for PR operations.

func NewClient

func NewClient() (*Client, error)

NewClient creates a GitHub client using available authentication. Priority: GITHUB_TOKEN env var > gh auth token command.

func NewClientWithHTTP

func NewClientWithHTTP(httpClient *http.Client, baseURL string) *Client

NewClientWithHTTP creates a Client with a custom HTTP client (for testing).

func (*Client) FetchFileContent

func (c *Client) FetchFileContent(ctx context.Context, ref *PRRef, path, headSHA string) ([]byte, error)

FetchFileContent fetches a file's content at the given ref (SHA or branch).

func (*Client) GetHeadSHA

func (c *Client) GetHeadSHA(ctx context.Context, ref *PRRef) (string, error)

GetHeadSHA returns the head commit SHA for a pull request.

func (*Client) ListMDFiles

func (c *Client) ListMDFiles(ctx context.Context, ref *PRRef) ([]PRFile, error)

ListMDFiles returns all .md files changed/added in a PR with their patches. Deleted files are excluded.

func (*Client) SubmitReview

func (c *Client) SubmitReview(ctx context.Context, ref *PRRef, review *gh.PullRequestReviewRequest) error

SubmitReview posts a PR review with inline comments.

type PRFile

type PRFile struct {
	Path  string // file path in the repo
	Patch string // unified diff patch
}

PRFile represents a Markdown file changed in a PR.

type PRRef

type PRRef struct {
	Owner  string
	Repo   string
	Number int
}

PRRef identifies a GitHub pull request.

func ParsePRURL

func ParsePRURL(rawURL string) (*PRRef, error)

ParsePRURL parses a GitHub PR URL into its components. Accepts: https://github.com/{owner}/{repo}/pull/{number}

type PRReviewComment

type PRReviewComment struct {
	Path      string
	Body      string
	Line      int
	StartLine int    // 0 = single line
	Side      string // "RIGHT" or "LEFT"
}

PRReviewComment represents a single inline comment on a PR.

func MapComment

func MapComment(c markdown.ReviewComment, path string, doc *markdown.Document) *PRReviewComment

MapComment converts a commd ReviewComment to a GitHub PR review comment. Overview (file-level) comments are skipped — not supported by the GitHub API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL