Documentation
¶
Index ¶
- type GhCli
- func (c *GhCli) ChangesSinceReview(_ context.Context) (map[int]int, error)
- func (c *GhCli) CommentOnPR(_ context.Context, number int, body string) error
- func (c *GhCli) CreatePR(ctx context.Context, p NewPR) (PullRequest, error)
- func (c *GhCli) CurrentUser(_ context.Context) (string, error)
- func (c *GhCli) GetPR(_ context.Context, number int) (PullRequest, error)
- func (c *GhCli) ListAllOpenPRs(_ context.Context) ([]PullRequest, error)
- func (c *GhCli) ListMergedPRsByHead(_ context.Context, heads []string) ([]PullRequest, error)
- func (c *GhCli) ListOpenPRs(_ context.Context) ([]PullRequest, error)
- func (c *GhCli) ListReviewRequestedPRs(_ context.Context) ([]PullRequest, error)
- func (c *GhCli) PRDiff(_ context.Context, number int) (string, error)
- func (c *GhCli) PRFiles(_ context.Context, number int) ([]PRFile, error)
- func (c *GhCli) RepoInfo(_ context.Context) (string, string, error)
- func (c *GhCli) UpdatePRBase(_ context.Context, number int, newBase string) error
- func (c *GhCli) UpdatePRBody(_ context.Context, number int, body string) error
- func (c *GhCli) UpdatePRTitle(_ context.Context, number int, newTitle string) error
- type GitHubClient
- type MockGhClient
- func (m *MockGhClient) ChangesSinceReview(_ context.Context) (map[int]int, error)
- func (m *MockGhClient) CommentOnPR(_ context.Context, number int, body string) error
- func (m *MockGhClient) CreatePR(_ context.Context, p NewPR) (PullRequest, error)
- func (m *MockGhClient) CurrentUser(_ context.Context) (string, error)
- func (m *MockGhClient) GetPR(_ context.Context, number int) (PullRequest, error)
- func (m *MockGhClient) ListAllOpenPRs(_ context.Context) ([]PullRequest, error)
- func (m *MockGhClient) ListMergedPRsByHead(_ context.Context, heads []string) ([]PullRequest, error)
- func (m *MockGhClient) ListOpenPRs(_ context.Context) ([]PullRequest, error)
- func (m *MockGhClient) ListReviewRequestedPRs(_ context.Context) ([]PullRequest, error)
- func (m *MockGhClient) PRDiff(_ context.Context, number int) (string, error)
- func (m *MockGhClient) PRFiles(_ context.Context, number int) ([]PRFile, error)
- func (m *MockGhClient) RepoInfo(_ context.Context) (string, string, error)
- func (m *MockGhClient) SetChangesSinceReview(byPR map[int]int)
- func (m *MockGhClient) SetPRDiff(number int, diff string)
- func (m *MockGhClient) SetPRFiles(number int, files []PRFile)
- func (m *MockGhClient) SetRepoInfo(owner, name string)
- func (m *MockGhClient) SetReviewRequested(numbers ...int)
- func (m *MockGhClient) SetState(number int, state string)
- func (m *MockGhClient) UpdatePRBase(_ context.Context, number int, newBase string) error
- func (m *MockGhClient) UpdatePRBody(_ context.Context, number int, body string) error
- func (m *MockGhClient) UpdatePRTitle(_ context.Context, number int, newTitle string) error
- type NewPR
- type PRFile
- type PullRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GhCli ¶
type GhCli struct {
// contains filtered or unexported fields
}
func (*GhCli) ChangesSinceReview ¶ added in v0.1.10
ChangesSinceReview fetches the open PRs the current user has reviewed and counts commits that landed after each review. Returns a map keyed by PR number. PRs the user hasn't reviewed are absent from the map.
Implementation: a single search to enumerate reviewed PRs, then per-PR fetches of reviews + commits. Capped at 50 PRs to bound the gh fanout.
func (*GhCli) CommentOnPR ¶ added in v0.1.20
func (*GhCli) ListAllOpenPRs ¶ added in v0.1.4
func (c *GhCli) ListAllOpenPRs(_ context.Context) ([]PullRequest, error)
func (*GhCli) ListMergedPRsByHead ¶
func (*GhCli) ListOpenPRs ¶
func (c *GhCli) ListOpenPRs(_ context.Context) ([]PullRequest, error)
func (*GhCli) ListReviewRequestedPRs ¶ added in v0.1.5
func (c *GhCli) ListReviewRequestedPRs(_ context.Context) ([]PullRequest, error)
func (*GhCli) UpdatePRBase ¶
func (*GhCli) UpdatePRBody ¶
type GitHubClient ¶
type GitHubClient interface {
CurrentUser(ctx context.Context) (string, error)
ListOpenPRs(ctx context.Context) ([]PullRequest, error)
// ListAllOpenPRs returns all open PRs in the repo regardless of author.
// Used by cn status --all to build the full PR dependency graph.
ListAllOpenPRs(ctx context.Context) ([]PullRequest, error)
// ListReviewRequestedPRs returns open PRs where the current user is a
// requested reviewer. Used by the Review tab.
ListReviewRequestedPRs(ctx context.Context) ([]PullRequest, error)
// ChangesSinceReview returns a map keyed by PR number of how many commits
// have landed on each PR after the current user's most recent review.
// Only includes PRs the user has actually reviewed; PRs absent from the
// map should be treated as "no prior review."
ChangesSinceReview(ctx context.Context) (map[int]int, error)
// ListMergedPRsByHead returns at most one merged PR per head (the most recent
// by number when there are duplicates). Heads that have no merged PR are
// simply absent from the result. Used by sync's squash-merged-parent detection.
ListMergedPRsByHead(ctx context.Context, heads []string) ([]PullRequest, error)
GetPR(ctx context.Context, number int) (PullRequest, error)
CreatePR(ctx context.Context, p NewPR) (PullRequest, error)
UpdatePRBody(ctx context.Context, number int, body string) error
UpdatePRBase(ctx context.Context, number int, newBase string) error
UpdatePRTitle(ctx context.Context, number int, newTitle string) error
// PRDiff returns the unified diff for a PR as a single string,
// equivalent to `gh pr diff <number> --patch`.
PRDiff(ctx context.Context, number int) (string, error)
// PRFiles returns each file in a PR along with its blob SHA after the
// change. Used for content-hash review state.
PRFiles(ctx context.Context, number int) ([]PRFile, error)
// RepoInfo returns the owner/name of the current repo, derived from the
// `gh` CLI's repo resolution (i.e. respects $GH_REPO or the local
// remote).
RepoInfo(ctx context.Context) (owner, name string, err error)
// CommentOnPR posts a plain comment to the PR (not a review comment).
// Used by the "request a plan" nudge.
CommentOnPR(ctx context.Context, number int, body string) error
}
type MockGhClient ¶
type MockGhClient struct {
User string
PRs map[int]PullRequest
NextNum int
Calls []string
// contains filtered or unexported fields
}
func NewMock ¶
func NewMock() *MockGhClient
func (*MockGhClient) ChangesSinceReview ¶ added in v0.1.10
func (*MockGhClient) CommentOnPR ¶ added in v0.1.20
func (*MockGhClient) CreatePR ¶
func (m *MockGhClient) CreatePR(_ context.Context, p NewPR) (PullRequest, error)
func (*MockGhClient) CurrentUser ¶
func (m *MockGhClient) CurrentUser(_ context.Context) (string, error)
func (*MockGhClient) GetPR ¶
func (m *MockGhClient) GetPR(_ context.Context, number int) (PullRequest, error)
func (*MockGhClient) ListAllOpenPRs ¶ added in v0.1.4
func (m *MockGhClient) ListAllOpenPRs(_ context.Context) ([]PullRequest, error)
func (*MockGhClient) ListMergedPRsByHead ¶
func (m *MockGhClient) ListMergedPRsByHead(_ context.Context, heads []string) ([]PullRequest, error)
func (*MockGhClient) ListOpenPRs ¶
func (m *MockGhClient) ListOpenPRs(_ context.Context) ([]PullRequest, error)
func (*MockGhClient) ListReviewRequestedPRs ¶ added in v0.1.5
func (m *MockGhClient) ListReviewRequestedPRs(_ context.Context) ([]PullRequest, error)
func (*MockGhClient) SetChangesSinceReview ¶ added in v0.1.10
func (m *MockGhClient) SetChangesSinceReview(byPR map[int]int)
func (*MockGhClient) SetPRDiff ¶ added in v0.1.10
func (m *MockGhClient) SetPRDiff(number int, diff string)
PRDiffs lets tests inject fixture diffs per PR number.
func (*MockGhClient) SetPRFiles ¶ added in v0.1.16
func (m *MockGhClient) SetPRFiles(number int, files []PRFile)
SetPRFiles lets tests inject the files list for a PR.
func (*MockGhClient) SetRepoInfo ¶ added in v0.1.16
func (m *MockGhClient) SetRepoInfo(owner, name string)
SetRepoInfo overrides the mock's repo owner/name.
func (*MockGhClient) SetReviewRequested ¶ added in v0.1.5
func (m *MockGhClient) SetReviewRequested(numbers ...int)
ReviewRequested holds PR numbers where the mock user is a requested reviewer.
func (*MockGhClient) SetState ¶
func (m *MockGhClient) SetState(number int, state string)
func (*MockGhClient) UpdatePRBase ¶
func (*MockGhClient) UpdatePRBody ¶
func (*MockGhClient) UpdatePRTitle ¶ added in v0.1.5
type PRFile ¶ added in v0.1.16
PRFile is one file's metadata from a PR — enough to drive per-file review state and basic diff summaries.
type PullRequest ¶
type PullRequest struct {
Number int
Title string
BaseRefName string
HeadRefName string
State string
Body string
MergeCommitSHA string
// CIStatus is the aggregate status check rollup: SUCCESS, FAILURE,
// PENDING, or "" (no checks configured).
CIStatus string
// ReviewDecision is APPROVED, CHANGES_REQUESTED, REVIEW_REQUIRED, or "".
ReviewDecision string
// UpdatedAt is the RFC3339 string from gh's updatedAt field.
UpdatedAt string
}