Skip to content

Commit

Permalink
Use Issues/Timelines API to retrieve all previously requested reviewe…
Browse files Browse the repository at this point in the history
…rs (#4)

The previous PR (#3) attempted to skip re-assigning aliases that had previously been assigned to the pull request.

Based on [the github documentation](https://docs.github.com/en/rest/pulls/review-requests?apiVersion=2022-11-28#get-all-requested-reviewers-for-a-pull-request), the previous API will only return current aliases that have been requested for review. This breaks two scenarios:
1) user aliases that have previously signed off will not be returned (and therefore re-added)
2) team aliases that have been signed off "on behalf of" a user alias will not be returned (they get removed entirely from the PR) (and therefore re-added).

This PR moves to using [the timelineevents API](https://docs.github.com/en/rest/issues/timeline?apiVersion=2022-11-28#about-timeline-events) which will give us every alias that has been requested regardless of their current status. Because the `timeline` can have a lot of events and the REST version doesn't allow us to filter, I opted to both swap to using [GraphQL version](https://docs.github.com/en/graphql/reference/unions#pullrequesttimelineitems) and added [pagination support.](https://github.com/octokit/plugin-paginate-graphql.js/?tab=readme-ov-file#usage).

The final change is to Unit Tests where we pull in [rewire](https://github.com/jhnns/rewire) in order to mock private methods of our `github.js` file. Primarily due to issues with mocking a constructor now that we had to [change the instantiation of octokit](https://github.com/actions/toolkit/tree/main/packages/github#extending-the-octokit-instance).
  • Loading branch information
jamoor-moj authored Feb 28, 2024
1 parent d8fc68e commit dc3795b
Show file tree
Hide file tree
Showing 7 changed files with 3,311 additions and 1,186 deletions.
Loading

0 comments on commit dc3795b

Please sign in to comment.