Revert "ci/github-script/labels: close empty PRs"

This reverts commit 402b41c125.

GitHub' API repeatedly returns wrong data which causes closed PRs when
the changes had not been merged, yet.

We have closed a bit more than 100 PRs overall, most of them initially -
the feature is not really that important overall.
This commit is contained in:
Wolfgang Walther
2025-11-18 09:20:08 +01:00
parent d2a32fd9a8
commit 28a32416fb
-43
View File
@@ -167,49 +167,6 @@ module.exports = async ({ github, context, core, dry }) => {
getUser,
})
// When the same change has already been merged to the target branch, a PR will still be
// open and display the same changes - but will not actually have any effect. This causes
// strange CI behavior, because the diff of the merge-commit is empty, no rebuilds will
// be detected, no maintainers pinged.
// We can just check the temporary merge commit, and if it's empty the PR can safely be
// closed - there are no further changes.
// We only do this for PRs, which are non-empty to start with. This avoids closing PRs
// which have been created with an empty commit for notification purposes, for example
// the yearly election notification for voters.
if (pull_request.merge_commit_sha && pull_request.changed_files > 0) {
const commit = (
await github.rest.repos.getCommit({
...context.repo,
ref: pull_request.merge_commit_sha,
})
).data
if (commit.files.length === 0) {
const body = [
`The diff for the temporary merge commit ${pull_request.merge_commit_sha} is empty.`,
'The changes in this PR have almost certainly already been merged to the target branch.',
].join('\n')
core.info(`PR #${item.number}: closed`)
if (!dry) {
await github.rest.issues.createComment({
...context.repo,
issue_number: pull_number,
body,
})
await github.rest.pulls.update({
...context.repo,
pull_number,
state: 'closed',
})
}
return {}
}
}
// Check for any human reviews other than the PR author, GitHub actions and other GitHub apps.
// Accounts could be deleted as well, so don't count them.
const reviews = (