@@ -146,28 +146,40 @@ async function isRepoCollaborator({ github, owner, repo, username }) {
146146 }
147147
148148 try {
149- await github . rest . repos . checkCollaborator ( {
149+ const response = await github . rest . repos . getCollaboratorPermissionLevel ( {
150150 owner,
151151 repo,
152152 username,
153153 } ) ;
154- return true ; // 204 = collaborator
154+
155+ const permission = response ?. data ?. permission ;
156+
157+ const isTeamMember =
158+ permission === 'admin' ||
159+ permission === 'write' ||
160+ permission === 'read' ;
161+
162+ console . log ( '[gfi-assign] isRepoCollaborator:' , {
163+ username,
164+ permission,
165+ isTeamMember,
166+ } ) ;
167+
168+ return isTeamMember ;
155169 } catch ( error ) {
156- if ( error ?. status === 404 || isPermissionFailure ( error ) ) {
157- if ( isPermissionFailure ( error ) ) {
158- console . log (
159- '[gfi-assign] isRepoCollaborator: insufficient permissions; treating as non-collaborator' ,
160- { owner, repo, username, status : error . status }
161- ) ;
162- }
170+ if ( isPermissionFailure ( error ) || error ?. status === 404 ) {
171+ console . log (
172+ '[gfi-assign] isRepoCollaborator: no permission / not collaborator' ,
173+ { username, status : error . status }
174+ ) ;
163175 return false ;
164176 }
165- throw error ; // unexpected error
177+ throw error ;
166178 }
167-
168179}
169180
170181
182+
171183/// START OF SCRIPT ///
172184module . exports = async ( { github, context } ) => {
173185 try {
@@ -221,6 +233,8 @@ module.exports = async ({ github, context }) => {
221233 } ) ;
222234
223235 if ( isTeamMember ) {
236+ // Team members comment for discussion, not assignment.
237+ // Do not send /assign reminders to collaborators.
224238 console . log ( '[gfi-assign] Skip reminder: commenter is collaborator' ) ;
225239 return ;
226240 }
0 commit comments