pr: processing checks

This commit is contained in:
2024-09-30 15:09:45 +02:00
parent e2498afc4d
commit 5027e98c04
4 changed files with 153 additions and 0 deletions

View File

@@ -469,6 +469,41 @@ func (gitea *GiteaTransport) GetPullRequestFileContent(pr *models.PullRequest, p
return gitea.GetRepositoryFileContent(pr.Head.Repo, pr.Head.Sha, path)
}
func (gitea *GiteaTransport) GetRecentPullRequests(org, repo string) ([]*models.PullRequest, error) {
prs := make([]*models.PullRequest, 0, 10)
var page int64
page = 1
sort := "recentupdate"
for {
res, err := gitea.client.Repository.RepoListPullRequests(
repository.NewRepoListPullRequestsParams().
WithOwner(org).
WithRepo(repo).
WithPage(&page).
WithSort(&sort),
gitea.transport.DefaultAuthentication)
if err != nil {
return nil, err
}
prs = append(prs, res.Payload...)
n := len(res.Payload)
if n < 10 {
break
}
// if pr is closed for more than a week, assume that we are done too
if time.Since(time.Time(res.Payload[n-1].Updated)) > 7 * 24 * time.Hour {
break
}
page++
}
return prs, nil
}
func (gitea *GiteaTransport) GetRecentCommits(org, repo, branch string, commitNo int64) ([]*models.Commit, error) {
not := false
var page int64