feat: correctly implement bitbucket & add OpenAIAdapter

This commit is contained in:
u80864958
2026-02-13 13:54:57 +01:00
parent b67125024c
commit 2cb64194b9
13 changed files with 408 additions and 91 deletions

View File

@@ -2,10 +2,11 @@ package gitea
import (
"bytes"
"context"
"io"
"git.schreifuchs.ch/schreifuchs/pierre-bot/internal/pierre"
"code.gitea.io/sdk/gitea"
"git.schreifuchs.ch/schreifuchs/pierre-bot/internal/pierre"
)
type Adapter struct {
@@ -22,15 +23,17 @@ func New(baseURL, token string) (*Adapter, error) {
}, nil
}
func (g *Adapter) GetDiff(owner, repo string, prID int) (io.Reader, error) {
func (g *Adapter) GetDiff(ctx context.Context, owner, repo string, prID int) (io.ReadCloser, error) {
g.client.SetContext(ctx)
diff, _, err := g.client.GetPullRequestDiff(owner, repo, int64(prID), gitea.PullRequestDiffOptions{})
if err != nil {
return nil, err
}
return bytes.NewReader(diff), nil
return io.NopCloser(bytes.NewReader(diff)), nil
}
func (g *Adapter) AddComment(owner, repo string, prID int, comment pierre.Comment) error {
func (g *Adapter) AddComment(ctx context.Context, owner, repo string, prID int, comment pierre.Comment) error {
g.client.SetContext(ctx)
opts := gitea.CreatePullReviewOptions{
State: gitea.ReviewStateComment,
Comments: []gitea.CreatePullReviewComment{