7c83365fc4
PR Ready Gate / clear-labels (pull_request) Successful in 2s
CI / test (pull_request) Successful in 18s
CI / review (anthropic--claude-4.6-sonnet, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Successful in 39s
CI / review (gpt-5, security, ., rodin/security-patterns, SECURITY_REVIEW.md, SECURITY_REVIEW_TOKEN) (pull_request) Successful in 1m48s
CI / review (gpt-5, gpt, GPT_REVIEW_TOKEN) (pull_request) Successful in 2m0s
- Create vcs/util.go with GetAllFilesInPath and BuildLineToPositionMap - Create vcs/util_test.go with comprehensive tests for both functions - Remove review.ContentEntry type, replace with vcs.ContentEntry - Remove review.GiteaClient interface, replace with vcs.FileReader - Update review/repo_persona.go to use vcs.FileReader - Update review/repo_persona_test.go to use vcs.ContentEntry - Update cmd/review-bot/main.go adapter to implement vcs.FileReader - Add Number and Base fields to vcs.PullRequest - Add CommitStatus type to vcs/types.go - Add GetFileContentAtRef to vcs.PRReader interface - Add GetCommitStatuses to vcs.PRReader interface - Add DismissReview to vcs.Reviewer interface - Add stub implementations on gitea.Client for new interface methods Closes #84, Closes #85, Closes #86
44 lines
1.9 KiB
Go
44 lines
1.9 KiB
Go
// Package vcs defines the shared VCS client interface and supporting types.
|
|
// Platform adapters (gitea, github) implement these interfaces so the core
|
|
// review logic can work with any VCS platform without platform-specific code.
|
|
package vcs
|
|
|
|
import "context"
|
|
|
|
// PRReader can fetch pull request metadata, diffs, and changed files.
|
|
type PRReader interface {
|
|
GetPullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)
|
|
GetPullRequestDiff(ctx context.Context, owner, repo string, number int) (string, error)
|
|
GetPullRequestFiles(ctx context.Context, owner, repo string, number int) ([]ChangedFile, error)
|
|
GetFileContentAtRef(ctx context.Context, owner, repo, path, ref string) (string, error)
|
|
GetCommitStatuses(ctx context.Context, owner, repo, sha string) ([]CommitStatus, error)
|
|
}
|
|
|
|
// FileReader can fetch file contents and list directory entries.
|
|
type FileReader interface {
|
|
GetFileContent(ctx context.Context, owner, repo, path, ref string) (string, error)
|
|
ListContents(ctx context.Context, owner, repo, path string) ([]ContentEntry, error)
|
|
}
|
|
|
|
// Reviewer can post, list, and delete pull request reviews.
|
|
type Reviewer interface {
|
|
PostReview(ctx context.Context, owner, repo string, number int, req ReviewRequest) (*Review, error)
|
|
ListReviews(ctx context.Context, owner, repo string, number int) ([]Review, error)
|
|
DeleteReview(ctx context.Context, owner, repo string, number int, reviewID int64) error
|
|
DismissReview(ctx context.Context, owner, repo string, number int, reviewID int64, message string) error
|
|
}
|
|
|
|
// Identity can report who the authenticated user is.
|
|
type Identity interface {
|
|
GetAuthenticatedUser(ctx context.Context) (string, error)
|
|
}
|
|
|
|
// Client is the full VCS interface: PR reads, file reads, review management, and identity.
|
|
// Platform adapters (gitea, github) implement this interface.
|
|
type Client interface {
|
|
PRReader
|
|
FileReader
|
|
Reviewer
|
|
Identity
|
|
}
|