This commit is contained in:
Adam Majer 2024-07-28 21:25:44 +02:00
parent ca7c9903d7
commit 65d821d388

View File

@ -20,6 +20,8 @@ const (
GitAuthor = "GiteaBot - Obs Staging"
BotName = "ObsStaging"
ObsBuildBot = "/obsbuild"
Username = "autogits_obs_staging_bot"
)
var GiteaToken string
@ -64,16 +66,32 @@ func processPullNotification(h *common.RequestHandler, notification *models.Noti
return
}
for _, reviewer := range pr.RequestedReviewers {
h.Log(reviewer.UserName)
}
obsClient, err := common.NewObsClient("api.opensuse.org")
if err != nil {
h.LogPlainError(err)
return
}
reviewRequested := false
for _, reviewer := range pr.RequestedReviewers {
if reviewer.UserName == Username {
reviewRequested = true
break
}
}
if !reviewRequested {
return
}
newReviews := make([]*models.PullReview, 0, len(reviews))
for _, review := range reviews {
if review.User.UserName == Username {
newReviews = append(newReviews, review)
}
}
reviews = newReviews
slices.SortFunc(reviews, func(a, b *models.PullReview) int {
return time.Time(a.Submitted).Compare(time.Time(b.Submitted))
})