dmitri.shuralyov.com/service/change/...

Add experimental support for approved event.
dmitshur committed 7 years ago commit b1d65570ed71fba833a2f9f533464ec71d55a0bc
Collapse all
githubapi/githubapi.go
@@ -460,10 +460,15 @@ func (s service) ListEvents(ctx context.Context, rs string, id uint64, opt *chan
							event
							RequestedReviewer struct {
								githubqlActor `graphql:"...on Actor"`
							}
						} `graphql:"...on ReviewRequestRemovedEvent"`
						PullRequestReview struct {
							Author    githubqlActor
							CreatedAt githubql.DateTime
							State     githubql.PullRequestReviewState
						} `graphql:"...on PullRequestReview"`
					}
				} `graphql:"timeline(first:100)"` // TODO: Paginate?
			} `graphql:"pullRequest(number:$prNumber)"`
		} `graphql:"repository(owner:$repositoryOwner,name:$repositoryName)"`
	}
@@ -522,10 +527,20 @@ func (s service) ListEvents(ctx context.Context, rs string, id uint64, opt *chan
		case "ReviewRequestRemovedEvent":
			e.Actor = ghActor(event.ReviewRequestRemovedEvent.Actor)
			e.CreatedAt = event.ReviewRequestRemovedEvent.CreatedAt.Time
			// TODO: Move RequestedReviewer field to changes-only events (it doesn't apply to issues).
			e.RequestedReviewer = ghActor(event.ReviewRequestRemovedEvent.RequestedReviewer.githubqlActor)
		case "PullRequestReview":
			switch event.PullRequestReview.State {
			case githubql.PullRequestReviewStateApproved:
				// TODO: Make this a thing that ListComments returns, etc. After all, it can have a non-empty body.
				e.Type = "ApprovedEvent"
			default:
				continue
			}
			e.Actor = ghActor(event.PullRequestReview.Author)
			e.CreatedAt = event.PullRequestReview.CreatedAt.Time
		default:
			continue
		}
		events = append(events, e)
	}