.
This commit is contained in:
parent
ca7c9903d7
commit
65d821d388
@ -20,6 +20,8 @@ const (
|
|||||||
GitAuthor = "GiteaBot - Obs Staging"
|
GitAuthor = "GiteaBot - Obs Staging"
|
||||||
BotName = "ObsStaging"
|
BotName = "ObsStaging"
|
||||||
ObsBuildBot = "/obsbuild"
|
ObsBuildBot = "/obsbuild"
|
||||||
|
|
||||||
|
Username = "autogits_obs_staging_bot"
|
||||||
)
|
)
|
||||||
|
|
||||||
var GiteaToken string
|
var GiteaToken string
|
||||||
@ -64,21 +66,37 @@ func processPullNotification(h *common.RequestHandler, notification *models.Noti
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, reviewer := range pr.RequestedReviewers {
|
|
||||||
h.Log(reviewer.UserName)
|
|
||||||
}
|
|
||||||
|
|
||||||
obsClient, err := common.NewObsClient("api.opensuse.org")
|
obsClient, err := common.NewObsClient("api.opensuse.org")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.LogPlainError(err)
|
h.LogPlainError(err)
|
||||||
return
|
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 {
|
slices.SortFunc(reviews, func(a, b *models.PullReview) int {
|
||||||
return time.Time(a.Submitted).Compare(time.Time(b.Submitted))
|
return time.Time(a.Submitted).Compare(time.Time(b.Submitted))
|
||||||
})
|
})
|
||||||
|
|
||||||
for idx := len(reviews)-1; idx >= 0; idx-- {
|
for idx := len(reviews) - 1; idx >= 0; idx-- {
|
||||||
review := reviews[idx]
|
review := reviews[idx]
|
||||||
h.Log("state: %s, body: %s, id:%d\n", string(review.State), review.Body, review.ID)
|
h.Log("state: %s, body: %s, id:%d\n", string(review.State), review.Body, review.ID)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user