Skip to content

Commit

Permalink
fix: remove filter reviews by publish timestamp (#387)
Browse files Browse the repository at this point in the history
Filtering the reviews by `publishedAt` is wrong, because the
`committedDate` of commit is a timestamp from when the commit is
created, not pushed to Github. So if the user has the commit locally for
some time, and someone reviews the PR in the meanwhile, the review is
not removed when the commit is pushed (because the review has a newer
timestamp than the commit).

The review filtering shouldn't be needed anyway, so it should be ok to
remove it completely.
  • Loading branch information
Balvajs authored Apr 9, 2024
1 parent e39775f commit 99339df
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 15 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
dismiss-stale-reviews:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# the git history must be fetched until merge-base commit of pull-request
fetch-depth: 0
Expand All @@ -43,12 +43,12 @@ jobs:
# repository pull requests: write
# organization members: read
#
# for more info on how to create GitHub App check tibdex/github-app-token action
- uses: tibdex/github-app-token@v1
# for more info on how to use GitHub App token check https://github.com/actions/create-github-app-token
- uses: actions/create-github-app-token@v1
id: get-token
with:
app_id: ${{ secrets.MANAGE_REVIEWS_BOT_ID }}
private_key: ${{ secrets.MANAGE_REVIEWS_BOT_PEM }}
private-key: ${{ secrets.MANAGE_REVIEWS_BOT_PEM }}
app-id: ${{ vars.MANAGE_REVIEWS_BOT_ID }}

- uses: balvajs/dismiss-stale-reviews@v3
with:
Expand Down
3 changes: 1 addition & 2 deletions dist/main.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/main.cjs.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/__generated__/get-pr-data.graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/get-pr-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const getPullRequestQuery = /* GraphQL */ `
id
}
}
publishedAt
}
pageInfo {
hasNextPage
Expand Down
6 changes: 1 addition & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ const run = async () => {
})

const latestApprovedReviews = latestReviews.filter(
({ state, publishedAt, commit }) =>
commit &&
state === 'APPROVED' &&
publishedAt &&
publishedAt < head.committedDate,
({ state, commit }) => commit && state === 'APPROVED',
)

debug(`Approving reviews: ${JSON.stringify(latestApprovedReviews, null, 2)}`)
Expand Down

0 comments on commit 99339df

Please sign in to comment.