package main /* import ( "bufio" "slices" "strings" "src.opensuse.org/autogits/common" "src.opensuse.org/autogits/common/gitea-generated/models" ) func fetchPRInfo(gitea GiteaPRInterface, pr common.BasicPR) PRInfo { data, reviews, _ := gitea.GetPullRequestAndReviews(pr.Org, pr.Repo, pr.Num) return PRInfo{ pr: data, reviews: reviews, } } func (rs *ReviewSet) appendPR(gitea GiteaPRInterface, pr common.BasicPR) { if slices.ContainsFunc(rs.prs, func(elem PRInfo) bool { return pr.Org == elem.pr.Base.Repo.Owner.UserName && pr.Repo == elem.pr.Base.Repo.Name && pr.Num == elem.pr.Index }) { return } prinfo := fetchPRInfo(gitea, pr) rs.prs = append(rs.prs, prinfo) _, childPRs := common.ExtractDescriptionAndPRs(bufio.NewScanner(strings.NewReader(prinfo.pr.Body))) for _, childPR := range childPRs { rs.appendPR(gitea, childPR) } } func NewReviewInstance(gitea GiteaPRInterface, maintainers MaintainershipData, org, repo string, prNum int) (*ReviewSet, error) { ret := &ReviewSet{ maintainers: maintainers, prs: []PRInfo{}, } ret.appendPR(gitea, common.BasicPR{Org: org, Repo: repo, Num: int64(prNum)}) return ret, nil } func isReviewMaintainerApproved(pkgMaintainersList []string, review *models.PullReview) bool { if review.State != common.ReviewStateApproved || review.Stale { return false; } if slices.Contains(pkgMaintainersList, review.User.UserName) { return true } return false; } func (prinfo *PRInfo) isMaintainerApproved(pkgMaintainersList []string) bool { for _, review := range prinfo.reviews { if isReviewMaintainerApproved(pkgMaintainersList, review) { return true } } return false } func (rs *ReviewSet) IsMaintainerApproved() (bool, error) { for _, prinfo := range rs.prs { pkgMaintainerList := rs.maintainers.ListPackageMaintainers(prinfo.pr.Base.Repo.Name) if !prinfo.isMaintainerApproved(pkgMaintainerList) { return false, nil } } return true, nil }*/