feat: correctly implement bitbucket & add OpenAIAdapter
This commit is contained in:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user