func getLastReviewerComment(obj *github.MungeObject, comments []*githubapi.IssueComment) *time.Time { var lastCommentTime *time.Time for _, reviewer := range obj.Issue.Assignees { lastReviewerCommentTime := comment.LastComment(comments, comment.Author(*reviewer), nil) if lastReviewerCommentTime == nil { continue } if lastCommentTime != nil && lastReviewerCommentTime.Before(*lastCommentTime) { continue } lastCommentTime = lastReviewerCommentTime } return lastCommentTime }
// assigneeActionNeeded returns true if we are waiting on an action from the reviewer. func isReviewerActionNeeded(obj *github.MungeObject) (bool, error) { comments, err := obj.ListComments() if err != nil { return false, err } lastAuthorCommentTime := comment.LastComment(comments, comment.Author(*obj.Issue.User), nil) lastReviewerCommentTime := getLastReviewerComment(obj, comments) if lastReviewerCommentTime == nil { // this implies that no reviewer has commented on the PR yet. return true, nil } if obj.LastModifiedTime().After(*lastReviewerCommentTime) { return true, nil } if lastAuthorCommentTime == nil { return false, nil } return lastReviewerCommentTime.Before(*lastAuthorCommentTime), nil }