fix: address remaining review findings (interface assertions, DismissReview ctx, import order, filepath param, spelling)
This commit is contained in:
@@ -847,9 +847,9 @@ func (a *giteaClientAdapter) ListContents(ctx context.Context, owner, repo, path
|
|||||||
return result, nil
|
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 != "" {
|
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)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -835,7 +835,7 @@ func (c *Client) ResolveComment(ctx context.Context, owner, repo string, comment
|
|||||||
// DismissReview dismisses a review on a pull request.
|
// DismissReview dismisses a review on a pull request.
|
||||||
// This is a stub for the vcs.Reviewer interface; full implementation is Phase 2.
|
// 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 {
|
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.
|
// GetFileContentAtRef fetches a file at a specific ref from a repo.
|
||||||
|
|||||||
@@ -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)
|
||||||
|
)
|
||||||
+2
-2
@@ -37,7 +37,7 @@ func GetAllFilesInPath(ctx context.Context, client FileReader, owner, repo, path
|
|||||||
var walk func(string) error
|
var walk func(string) error
|
||||||
walk = func(dir string) error {
|
walk = func(dir string) error {
|
||||||
if err := ctx.Err(); err != nil {
|
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)
|
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 {
|
for _, entry := range entries {
|
||||||
if err := ctx.Err(); err != nil {
|
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 {
|
switch entry.Type {
|
||||||
|
|||||||
+4
-4
@@ -2,8 +2,8 @@ package vcs_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strings"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"gitea.weiker.me/rodin/review-bot/vcs"
|
"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())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
cancel() // Cancel immediately
|
cancel() // Cancel immediately
|
||||||
|
|
||||||
@@ -322,9 +322,9 @@ func TestGetAllFilesInPath_ErrorPropagation(t *testing.T) {
|
|||||||
}
|
}
|
||||||
_, err := vcs.GetAllFilesInPath(ctx, client, "owner", "repo", "src")
|
_, err := vcs.GetAllFilesInPath(ctx, client, "owner", "repo", "src")
|
||||||
if err == nil {
|
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)
|
t.Errorf("expected context cancellation error, got: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user