feat(vcs): Gitea adapter with diff-position translation
Implements the Gitea adapter (gitea.Adapter) that satisfies vcs.Client. Key components: - gitea/adapter.go: Adapter struct wrapping *Client with all vcs.Client methods - gitea/position.go: BuildPositionToLineMap for diff-position → line translation - gitea/adapter_test.go: Tests for all mapping methods and event translation - gitea/position_test.go: Tests for position translation edge cases Translation details: - ReviewEvent: APPROVE → APPROVED (Gitea-native) - PostReview: fetches diff, builds position map, translates each comment - Deletion-targeted positions map to nearest non-deletion line below - All field-mapping methods tested (GetPullRequest, GetPullRequestFiles, ListReviews, GetCommitStatuses, ListContents) Also: - Added Base field to gitea.PullRequest struct - Updated conformance tests to assert Adapter (not raw Client) satisfies vcs.Client - Removed phase2 build tag from conformance tests Closes #79
This commit is contained in:
+4
-20
@@ -1,5 +1,3 @@
|
||||
//go:build phase2
|
||||
|
||||
package vcs_test
|
||||
|
||||
import (
|
||||
@@ -7,21 +5,7 @@ import (
|
||||
"gitea.weiker.me/rodin/review-bot/vcs"
|
||||
)
|
||||
|
||||
// Compile-time assertion: documents the gap between gitea.Client and vcs.Client.
|
||||
// Guarded by the "phase2" build tag — enable once the Gitea adapter bridges these gaps:
|
||||
//
|
||||
// 1. PostReview signature mismatch:
|
||||
// gitea.Client: PostReview(ctx, owner, repo, number, event, body string, comments []gitea.ReviewComment)
|
||||
// vcs.Reviewer: PostReview(ctx, owner, repo, number, req vcs.ReviewRequest)
|
||||
//
|
||||
// 2. GetFileContent signature mismatch:
|
||||
// gitea.Client: GetFileContent(ctx, owner, repo, filepath string) [no ref; uses default branch]
|
||||
// vcs.FileReader: GetFileContent(ctx, owner, repo, path, ref string)
|
||||
// (gitea.Client has GetFileContentRef for the ref variant)
|
||||
//
|
||||
// 3. ReviewComment type mismatch:
|
||||
// gitea.ReviewComment uses NewPosition int64 (Gitea line-number convention)
|
||||
// vcs.ReviewComment uses Position int (GitHub diff-position convention)
|
||||
//
|
||||
// The Gitea adapter (Phase 2) will wrap gitea.Client to bridge these gaps.
|
||||
var _ vcs.Client = (*gitea.Client)(nil)
|
||||
// Compile-time assertion: the gitea.Adapter satisfies vcs.Client.
|
||||
// (The raw gitea.Client does NOT satisfy vcs.Client due to signature differences;
|
||||
// the Adapter bridges them.)
|
||||
var _ vcs.Client = (*gitea.Adapter)(nil)
|
||||
|
||||
Reference in New Issue
Block a user