feat(vcs): extract interfaces and types from gitea/ (Phase 1, #78)
Add vcs/interfaces.go and vcs/types.go as the foundation for multi-platform VCS support. Interfaces are discovered from working gitea/client.go code, not invented in a vacuum. vcs/interfaces.go — role-based interfaces: - PRReader: GetPullRequest, GetPullRequestDiff, GetPullRequestFiles - FileReader: GetFileContent (path + ref), ListContents - Reviewer: PostReview (ReviewRequest), ListReviews, DeleteReview - Identity: GetAuthenticatedUser - Client: all four composed vcs/types.go — types extracted from gitea/: - PullRequest, ChangedFile, ContentEntry, Review (identical to gitea/) - ReviewComment: uses GitHub diff-position convention (Position int, CommitID string) instead of Gitea's NewPosition int64 - ReviewRequest: new type wrapping Body, Event, Comments vcs/check.go (//go:build ignore) — documents the gaps gitea.Client must bridge in Phase 2: 1. PostReview signature mismatch (event+body+[]ReviewComment vs ReviewRequest) 2. GetFileContent missing ref parameter 3. ReviewComment type mismatch (NewPosition vs Position/CommitID) No behavior changes. All existing tests pass.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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)
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user