diff --git a/cmd/review-bot/main.go b/cmd/review-bot/main.go index 44f1306..40efc46 100644 --- a/cmd/review-bot/main.go +++ b/cmd/review-bot/main.go @@ -838,9 +838,9 @@ func (a *giteaClientAdapter) ListContents(ctx context.Context, owner, repo, path return result, nil } -func (a *giteaClientAdapter) GetFileContent(ctx context.Context, owner, repo, filepath, ref string) (string, error) { +func (a *giteaClientAdapter) GetFileContent(ctx context.Context, owner, repo, filePath, ref string) (string, error) { if ref != "" { - return a.client.GetFileContentRef(ctx, owner, repo, filepath, ref) + return a.client.GetFileContentRef(ctx, owner, repo, filePath, ref) } - return a.client.GetFileContent(ctx, owner, repo, filepath) + return a.client.GetFileContent(ctx, owner, repo, filePath) } diff --git a/gitea/client.go b/gitea/client.go index ab963a6..3284314 100644 --- a/gitea/client.go +++ b/gitea/client.go @@ -835,7 +835,7 @@ func (c *Client) ResolveComment(ctx context.Context, owner, repo string, comment // DismissReview dismisses a review on a pull request. // This is a stub for the vcs.Reviewer interface; full implementation is Phase 2. func (c *Client) DismissReview(ctx context.Context, owner, repo string, number int, reviewID int64, message string) error { - return fmt.Errorf("DismissReview: %w", errors.ErrUnsupported) + return fmt.Errorf("dismiss review %d on %s/%s#%d: %w", reviewID, owner, repo, number, errors.ErrUnsupported) } // GetFileContentAtRef fetches a file at a specific ref from a repo. diff --git a/gitea/conformance_test.go b/gitea/conformance_test.go new file mode 100644 index 0000000..08b7f97 --- /dev/null +++ b/gitea/conformance_test.go @@ -0,0 +1,25 @@ +//go:build phase2 + +package gitea_test + +import ( + "gitea.weiker.me/rodin/review-bot/gitea" + "gitea.weiker.me/rodin/review-bot/vcs" +) + +// Compile-time interface conformance assertions. +// These will verify gitea.Client satisfies vcs interfaces once the Phase 2 +// adapter bridges the method signature gaps: +// +// - PRReader: GetPullRequest returns *gitea.PullRequest (needs *vcs.PullRequest) +// - PRReader: GetPullRequestFiles returns []gitea.ChangedFile (needs []vcs.ChangedFile) +// - FileReader: GetFileContent lacks ref parameter +// - Reviewer: PostReview uses (event, body, comments) instead of vcs.ReviewRequest +// +// Remove the phase2 build tag once the adapter is complete. +var ( + _ vcs.PRReader = (*gitea.Client)(nil) + _ vcs.FileReader = (*gitea.Client)(nil) + _ vcs.Reviewer = (*gitea.Client)(nil) + _ vcs.Identity = (*gitea.Client)(nil) +) diff --git a/vcs/util.go b/vcs/util.go index f1266c8..62f2015 100644 --- a/vcs/util.go +++ b/vcs/util.go @@ -37,7 +37,7 @@ func GetAllFilesInPath(ctx context.Context, client FileReader, owner, repo, path var walk func(string) error walk = func(dir string) error { if err := ctx.Err(); err != nil { - return fmt.Errorf("context cancelled during traversal: %w", err) + return fmt.Errorf("context canceled during traversal: %w", err) } entries, err := client.ListContents(ctx, owner, repo, dir) @@ -47,7 +47,7 @@ func GetAllFilesInPath(ctx context.Context, client FileReader, owner, repo, path for _, entry := range entries { if err := ctx.Err(); err != nil { - return fmt.Errorf("context cancelled during traversal: %w", err) + return fmt.Errorf("context canceled during traversal: %w", err) } switch entry.Type { diff --git a/vcs/util_test.go b/vcs/util_test.go index 8436884..6d1e42a 100644 --- a/vcs/util_test.go +++ b/vcs/util_test.go @@ -2,8 +2,8 @@ package vcs_test import ( "context" - "strings" "fmt" + "strings" "testing" "gitea.weiker.me/rodin/review-bot/vcs" @@ -306,7 +306,7 @@ func TestGetAllFilesInPath_ErrorPropagation(t *testing.T) { } }) - t.Run("cancelled context propagates", func(t *testing.T) { + t.Run("canceled context propagates", func(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) cancel() // Cancel immediately @@ -322,9 +322,9 @@ func TestGetAllFilesInPath_ErrorPropagation(t *testing.T) { } _, err := vcs.GetAllFilesInPath(ctx, client, "owner", "repo", "src") if err == nil { - t.Fatal("expected error from cancelled context, got nil") + t.Fatal("expected error from canceled context, got nil") } - if !strings.Contains(err.Error(), "context cancelled") { + if !strings.Contains(err.Error(), "context canceled") { t.Errorf("expected context cancellation error, got: %v", err) } })