ac6d34f5bd
PR Ready Gate / clear-labels (pull_request) Successful in 2s
CI / test (pull_request) Successful in 19s
CI / review (anthropic--claude-4.6-sonnet, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Successful in 56s
CI / review (gpt-5, security, ., rodin/security-patterns, SECURITY_REVIEW.md, SECURITY_REVIEW_TOKEN) (pull_request) Successful in 1m51s
CI / review (gpt-5, gpt, GPT_REVIEW_TOKEN) (pull_request) Successful in 2m21s
- Introduce vcs.VCSProvider typed constant (replaces plain string provider) - Introduce vcs.ReviewSuperseder optional interface for supersede logic - Implement SupersedeReviews on gitea.Adapter (edit + resolve) and github.Client (dismiss) - Remove concrete type assertion client.(*gitea.Adapter) from main - Remove redundant baseURL fallback for github (NewClient defaults it) - Condense --gitea-url alias comment block - Fix fetchPatterns comment (empty paths are skipped, not fetched) - Add default panic to VCS client init switch Addresses: #19607, #19608, #19609, #19610, #19621, #19622, #19623
61 lines
2.9 KiB
Go
61 lines
2.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
|
|
}
|
|
|
|
// ReviewerSelfRequester is an optional interface implemented by adapters that support
|
|
// requesting the authenticated user as a reviewer on a pull request. This is used for
|
|
// Gitea-specific behavior (ensuring the bot appears in required-reviewer checks).
|
|
// Consumers should use interface assertion: if sr, ok := client.(ReviewerSelfRequester); ok { ... }
|
|
type ReviewerSelfRequester interface {
|
|
RequestReviewerSelf(ctx context.Context, owner, repo string, number int, user string) error
|
|
}
|
|
|
|
// ReviewSuperseder is an optional interface implemented by adapters that support
|
|
// marking old reviews as superseded. For Gitea this means editing the review body
|
|
// with a link to the new review and resolving inline comments. For GitHub this
|
|
// means dismissing old reviews.
|
|
// Consumers should use interface assertion: if rs, ok := client.(ReviewSuperseder); ok { ... }
|
|
type ReviewSuperseder interface {
|
|
SupersedeReviews(ctx context.Context, owner, repo string, prNumber int, oldReviews []Review, newReviewID int64, baseURL, sentinel string) error
|
|
}
|