Skip to content

Commit 3e624ee

Browse files
authored
Merge pull request #1 from Abhijeet2409/fix-gfi-notification
Fix gfi notification
2 parents 97de974 + c105dfe commit 3e624ee

2 files changed

Lines changed: 26 additions & 11 deletions

File tree

.github/scripts/bot-gfi-assign-on-comment.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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 ///
172184
module.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
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
205205
- Update changelog workflow to trigger automatically on pull requests instead of manual dispatch (#1567)
206206

207207
### Fixed
208+
- Ensured that the GFI assignment bot skips posting `/assign` reminders for repository collaborators to avoid unnecessary notifications.(#1568).
208209
- Reduced notification spam by skipping the entire advanced qualification job for non-advanced issues and irrelevant events (#1517)
209210
- Aligned token freeze example filename references and improved error handling by catching broader exceptions with clearer messages. (#1412)
210211
- Fixed jq syntax in bot-office-hours.sh (#1502)

0 commit comments

Comments
 (0)