github

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildReviewBody

func BuildReviewBody(summary string, comments []ReviewComment) ([]byte, error)

func FetchChecks

func FetchChecks(ctx context.Context, url string) (string, error)

FetchChecks returns the formatted output of `gh pr checks <url>`, listing every CI check on the PR with status + link. `gh pr checks` exits non-zero when any check failed, but the listing is still on stdout — so we keep stdout regardless of exit code.

func FetchDiff

func FetchDiff(ctx context.Context, url string) (string, error)

func PostPendingReview

func PostPendingReview(ctx context.Context, prURL, summary string, comments []ReviewComment) (int64, error)

func PostQuickReview

func PostQuickReview(ctx context.Context, prURL, event, body string) (int64, error)

PostQuickReview posts a review with no inline comments and an explicit event ("APPROVE", "COMMENT", "REQUEST_CHANGES"). Used by the TUI's a/b keys for one-shot reviews without running Claude.

Types

type CLIClient

type CLIClient struct{}

func (CLIClient) FetchDiff

func (CLIClient) FetchDiff(ctx context.Context, url string) (string, error)

func (CLIClient) FetchPRDetail

func (CLIClient) FetchPRDetail(ctx context.Context, url string) (*PRDetail, error)

type Check

type Check struct {
	Name       string `json:"name"`
	Status     string `json:"status"`
	Conclusion string `json:"conclusion"`
}

type ChecksSummary

type ChecksSummary struct {
	Passed       int
	Failed       int
	Pending      int
	FailedNames  []string
	PendingNames []string
}

func SummarizeChecks

func SummarizeChecks(checks []Check) ChecksSummary

type Comment

type Comment struct {
	AuthorRaw struct {
		Login string `json:"login"`
	} `json:"author"`
	Body      string `json:"body"`
	CreatedAt string `json:"createdAt"`
}

func (Comment) Author

func (c Comment) Author() string

type InlineComment

type InlineComment struct {
	ID        int64  `json:"id"`
	Path      string `json:"path"`
	Line      int    `json:"line"`
	Body      string `json:"body"`
	CreatedAt string `json:"created_at"`
	User      struct {
		Login string `json:"login"`
	} `json:"user"`
}

InlineComment is a per-line review comment fetched via `gh api`.

type Label

type Label struct {
	Name  string `json:"name"`
	Color string `json:"color"`
}

type PR

type PR struct {
	Number      int    `json:"number"`
	Title       string `json:"title"`
	URL         string `json:"url"`
	Author      string
	HeadRefName string `json:"headRefName"`
	BaseRefName string `json:"baseRefName"`
	UpdatedAt   string `json:"updatedAt"`
	CreatedAt   string `json:"createdAt"`
	Repo        string // populated from RepositoryRaw.NameWithOwner

	AuthorRaw struct {
		Login string `json:"login"`
	} `json:"author"`
	RepositoryRaw struct {
		NameWithOwner string `json:"nameWithOwner"`
	} `json:"repository"`
}

func SearchPRs

func SearchPRs(ctx context.Context, q Query) ([]PR, error)

type PRDetail

type PRDetail struct {
	PR
	Body             string          `json:"body"`
	Checks           []Check         `json:"statusCheckRollup"`
	Comments         []Comment       `json:"comments"`
	Reviews          []Review        `json:"reviews"`
	State            string          `json:"state"` // OPEN, CLOSED, MERGED
	IsDraft          bool            `json:"isDraft"`
	ReviewDecision   string          `json:"reviewDecision"` // APPROVED, CHANGES_REQUESTED, REVIEW_REQUIRED, ""
	MergeStateStatus string          `json:"mergeStateStatus"`
	Mergeable        string          `json:"mergeable"` // MERGEABLE, CONFLICTING, UNKNOWN
	Labels           []Label         `json:"labels"`
	Assignees        []User          `json:"assignees"`
	ReviewRequests   []User          `json:"reviewRequests"`
	UpdatedAt        string          `json:"updatedAt"`
	ChangedFiles     int             `json:"changedFiles"`
	Additions        int             `json:"additions"`
	Deletions        int             `json:"deletions"`
	Inline           []InlineComment `json:"-"`
}

func FetchPRDetail

func FetchPRDetail(ctx context.Context, url string) (*PRDetail, error)

type Query

type Query int
const (
	QueryAuthored Query = iota
	QueryReviewRequested
	QueryMentioned
)

func (Query) Label

func (q Query) Label() string

type Review

type Review struct {
	AuthorRaw struct {
		Login string `json:"login"`
	} `json:"author"`
	Body        string `json:"body"`
	State       string `json:"state"` // APPROVED, CHANGES_REQUESTED, COMMENTED, PENDING
	SubmittedAt string `json:"submittedAt"`
}

func (Review) Author

func (r Review) Author() string

type ReviewComment

type ReviewComment struct {
	Path       string `json:"path"`
	Line       int    `json:"line"`
	Side       string `json:"side"` // "LEFT" or "RIGHT"
	Body       string `json:"body"`
	Severity   string `json:"-"` // internal only, never sent to GitHub
	Suggestion string `json:"-"` // internal only; appended to Body on post
}

type Reviewer

type Reviewer struct{}

func (Reviewer) PostPendingReview

func (Reviewer) PostPendingReview(ctx context.Context, prURL, summary string, c []ReviewComment) (int64, error)

type User

type User struct {
	Login string `json:"login"`
}

Jump to

Keyboard shortcuts

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