| 1 | package github |
| 2 | |
| 3 | import "context" |
| 4 | |
| 5 | // Client defines all GitHub operations Klaus uses. |
| 6 | type Client interface { |
| 7 | // Repository info |
| 8 | GetRepoOwnerAndName(ctx context.Context) (owner string, repo string, err error) |
| 9 | GetRepoOwnerAndNameFromDir(ctx context.Context, dir string) (owner string, repo string, err error) |
| 10 | |
| 11 | // PR queries |
| 12 | GetCI(ctx context.Context, prRef string) string |
| 13 | GetConflicts(ctx context.Context, prRef string) string |
| 14 | GetCommitsBehind(ctx context.Context, prRef string) int |
| 15 | GetReviewDecision(ctx context.Context, prRef string) string |
| 16 | GetState(ctx context.Context, prRef string) string // OPEN, MERGED, CLOSED, StateNoAccess or UNKNOWN |
| 17 | IsDraft(ctx context.Context, prRef string) bool |
| 18 | GetLabels(ctx context.Context, prRef string) []string |
| 19 | GetBranch(ctx context.Context, prRef string) (string, error) |
| 20 | GetURL(ctx context.Context, prRef string) (string, error) |
| 21 | GetTitle(ctx context.Context, prRef string) string |
| 22 | PRDiff(ctx context.Context, prRef string) (string, error) |
| 23 | |
| 24 | // Batched PR status, for polling |
| 25 | PRSnapshots(ctx context.Context, slug string, numbers []int, activity bool) (map[int]*PRSnapshot, error) |
| 26 | CommitsBehindSHA(ctx context.Context, slug, base, head string) (int, error) |
| 27 | |
| 28 | // PR mutations |
| 29 | Merge(ctx context.Context, prNumber, mergeMethod string, deleteBranch bool) error |
| 30 | UpdateBranch(ctx context.Context, prNumber string) error |
| 31 | |
| 32 | // Review operations |
| 33 | FetchPRReviewComments(ctx context.Context, owner, repo, prNumber string) ([]PRReviewComment, error) |
| 34 | ReplyToReviewComment(ctx context.Context, owner, repo, prNumber string, commentID int64, body string) error |
| 35 | FetchReviewThreads(ctx context.Context, owner, repo string, prNumber int) ([]ReviewThread, error) |
| 36 | ResolveReviewThread(ctx context.Context, threadID string) error |
| 37 | |
| 38 | // Collaborators |
| 39 | FetchCollaborators(ctx context.Context, owner, repo string) ([]string, error) |
| 40 | |
| 41 | // Generic API |
| 42 | APIGet(ctx context.Context, path string) ([]byte, error) |
| 43 | APIPost(ctx context.Context, path string, fields map[string]string) error |
| 44 | APIPostJSON(ctx context.Context, path string, body interface{}) ([]byte, error) |
| 45 | |
| 46 | // PR metadata (multi-field fetch for track command) |
| 47 | FetchPRMetadata(ctx context.Context, prNumber, repo string) (prURL, title, headBranch, state string, err error) |
| 48 | |
| 49 | // Repo operations |
| 50 | GetAuthenticatedUser(ctx context.Context) (login string, err error) |
| 51 | } |