ci/github-script/merge: list eligible users in comment
When a user tries to merge a PR, but is not allowed to, it is helpful to explicitly list the users who *are* allowed. This helps explaining *why* the merge-eligible label was set. I objected to this proposal before, because it would incur too many API requests. But after we have restructured the checklist, this is not actually true anymore - we can now sensibly run this only when a comment is posted and not whenever we check a PR for eligibility.
This commit is contained in:
@@ -80,6 +80,7 @@ function runChecklist({
|
||||
|
||||
return {
|
||||
checklist,
|
||||
eligible,
|
||||
result,
|
||||
}
|
||||
}
|
||||
@@ -119,6 +120,7 @@ async function handleMerge({
|
||||
events,
|
||||
maintainers,
|
||||
getTeamMembers,
|
||||
getUser,
|
||||
}) {
|
||||
const pull_number = pull_request.number
|
||||
|
||||
@@ -240,7 +242,7 @@ async function handleMerge({
|
||||
}
|
||||
}
|
||||
|
||||
const { result, checklist } = runChecklist({
|
||||
const { result, eligible, checklist } = runChecklist({
|
||||
committers,
|
||||
events,
|
||||
files,
|
||||
@@ -270,6 +272,18 @@ async function handleMerge({
|
||||
'',
|
||||
]
|
||||
|
||||
if (eligible.size > 0 && !eligible.has(comment.user.id)) {
|
||||
const users = await Promise.all(
|
||||
Array.from(eligible, async (id) => (await getUser(id)).login),
|
||||
)
|
||||
body.push(
|
||||
'> [!TIP]',
|
||||
'> Maintainers eligible to merge are:',
|
||||
...users.map((login) => `> - ${login}`),
|
||||
'',
|
||||
)
|
||||
}
|
||||
|
||||
if (result) {
|
||||
await react('ROCKET')
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user