wip
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
transport "github.com/go-openapi/runtime/client"
|
||||
@@ -59,8 +60,12 @@ type GiteaMaintainershipInterface interface {
|
||||
FetchMaintainershipFile(org, prjGit, branch string) ([]byte, error)
|
||||
}
|
||||
|
||||
type GiteaPRReviewFetcher interface {
|
||||
GetPullRequestAndReviews(org, project string, num int64) (*models.PullRequest, []*models.PullReview, error)
|
||||
type GiteaPRFetcher interface {
|
||||
GetPullRequest(org, project string, num int64) (*models.PullRequest, error)
|
||||
}
|
||||
|
||||
type GiteaReviewFetcher interface {
|
||||
GetPullRequestReviews(org, project string, num int64) ([]*models.PullReview, error)
|
||||
}
|
||||
|
||||
type GiteaReviewRequester interface {
|
||||
@@ -74,7 +79,7 @@ type GiteaReviewer interface {
|
||||
type Gitea interface {
|
||||
GiteaReviewRequester
|
||||
GiteaReviewer
|
||||
GiteaPRReviewFetcher
|
||||
GiteaPRFetcher
|
||||
|
||||
GetPullNotifications(since *time.Time) ([]*models.NotificationThread, error)
|
||||
SetNotificationRead(notificationId int64) error
|
||||
@@ -110,7 +115,7 @@ func (gitea *GiteaTransport) FetchMaintainershipFile(org, repo, branch string) (
|
||||
return gitea.GetRepositoryFileContent(org, repo, branch, MaintainershipFile)
|
||||
}
|
||||
|
||||
func (gitea *GiteaTransport) GetPullRequestAndReviews(org, project string, num int64) (*models.PullRequest, []*models.PullReview, error) {
|
||||
func (gitea *GiteaTransport) GetPullRequest(org, project string, num int64) (*models.PullRequest, error) {
|
||||
pr, err := gitea.client.Repository.RepoGetPullRequest(
|
||||
repository.NewRepoGetPullRequestParams().
|
||||
WithDefaults().
|
||||
@@ -120,26 +125,39 @@ func (gitea *GiteaTransport) GetPullRequestAndReviews(org, project string, num i
|
||||
gitea.transport.DefaultAuthentication,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return pr.Payload, err
|
||||
}
|
||||
|
||||
func (gitea *GiteaTransport) GetPullReviews(org, project string, num int64) ([]*models.PullReview, error) {
|
||||
limit := int64(20)
|
||||
var page int64
|
||||
|
||||
var allReviews []*models.PullReview
|
||||
|
||||
for {
|
||||
reviews, err := gitea.client.Repository.RepoListPullReviews(
|
||||
repository.NewRepoListPullReviewsParams().
|
||||
WithDefaults().
|
||||
WithOwner(org).
|
||||
WithRepo(project).
|
||||
WithIndex(num).
|
||||
WithPage(&page).
|
||||
WithLimit(&limit),
|
||||
gitea.transport.DefaultAuthentication,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
allReviews = slices.Concat(allReviews, reviews.Payload)
|
||||
if len(reviews.Payload) < int(limit) {
|
||||
break
|
||||
}
|
||||
page++
|
||||
}
|
||||
|
||||
limit := int64(1000)
|
||||
reviews, err := gitea.client.Repository.RepoListPullReviews(
|
||||
repository.NewRepoListPullReviewsParams().
|
||||
WithDefaults().
|
||||
WithOwner(org).
|
||||
WithRepo(project).
|
||||
WithIndex(num).
|
||||
WithLimit(&limit),
|
||||
gitea.transport.DefaultAuthentication,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return pr.Payload, reviews.Payload, nil
|
||||
return allReviews, nil
|
||||
}
|
||||
|
||||
func (gitea *GiteaTransport) GetPullNotifications(since *time.Time) ([]*models.NotificationThread, error) {
|
||||
|
||||
Reference in New Issue
Block a user