Skip to content

Commit b5b8efb

Browse files
committed
isAllowed(): needs a context, owner and repo
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent aaf7a32 commit b5b8efb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

GitForWindowsHelper/cascading-runs.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const getToken = (() => {
1111
return async (context, owner, repo) => tokens[[owner, repo]] || (tokens[[owner, repo]] = await get(context, owner, repo))
1212
})()
1313

14-
const isAllowed = async (login) => {
14+
const isAllowed = async (context, owner, repo, login) => {
1515
if (login === 'gitforwindowshelper[bot]') return true
1616
const getCollaboratorPermissions = require('./get-collaborator-permissions')
1717
const token = await getToken()
@@ -123,7 +123,7 @@ const cascadingRuns = async (context, req) => {
123123
throw new Error(`Refusing to handle cascading run in ${checkRunOwner}/${checkRunRepo}`)
124124
}
125125

126-
if (!await isAllowed(sender)) throw new Error(`${sender} is not allowed to do that`)
126+
if (!await isAllowed(context, checkRunOwner, checkRunRepo, sender)) throw new Error(`${sender} is not allowed to do that`)
127127

128128
const comment = await triggerGitArtifactsRuns(context, checkRunOwner, checkRunRepo, checkRun)
129129

@@ -147,7 +147,7 @@ const cascadingRuns = async (context, req) => {
147147
if (checkRunOwner === 'git-for-windows'
148148
&& checkRunRepo === 'git'
149149
&& name.startsWith('git-artifacts-')) {
150-
if (!await isAllowed(sender)) throw new Error(`${sender} is not allowed to do that`)
150+
if (!await isAllowed(context, checkRunOwner, checkRunRepo, sender)) throw new Error(`${sender} is not allowed to do that`)
151151

152152
const output = req.body.check_run.output
153153
const match = output.summary.match(
@@ -279,7 +279,7 @@ const handlePush = async (context, req) => {
279279

280280
if (ref !== 'refs/heads/main') return `Ignoring push to ${ref}`
281281

282-
if (!await isAllowed(sender)) throw new Error(`${sender} is not allowed to do that`)
282+
if (!await isAllowed(context, pushOwner, pushRepo, sender)) throw new Error(`${sender} is not allowed to do that`)
283283

284284
// See whether there was are already a `tag-git` check-run for this commit
285285
const { listCheckRunsForCommit, queueCheckRun, updateCheckRun } = require('./check-runs')

0 commit comments

Comments
 (0)