Skip to content

Commit

Permalink
wip: log out the requested reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
wassimk committed Jun 3, 2024
1 parent c97c26f commit 4754751
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ async function run() {
const owner = github.context.payload.repository.owner.login
const repo = github.context.payload.repository.name

const reviewRequests = await octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers', {
owner,
repo,
pull_number
}).then((res) => {
reviewRequests = res.data.users.map(u => u.login)
})
console.og(`reviewRequests: ${JSON.stringify(reviewRequests, undefined, 2)}`)

let requestedReviewers = []
reviewRequests.forEach(reviewer => {
requestedReviewers.push(reviewer.login)
})
console.log(`requestedReviewers: ${JSON.stringify(requestedReviewers, undefined, 2)}`)

const prReviews = await octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews', {
owner,
repo,
Expand All @@ -19,7 +34,8 @@ async function run() {
let filteredPrReviews = prReviews.data.reverse().filter(review => review.state !== "COMMENTED");
filteredPrReviews.forEach(review => {
const reviewer = review.user.login
if (!reviews.find(r => r.reviewer === reviewer)) {
if (!reviews.find(r => r.reviewer === reviewer && !reviewRequests.includes(reviewer))) {

reviews.push({ reviewer: reviewer, state: review.state })
}
});
Expand Down

0 comments on commit 4754751

Please sign in to comment.