From bf05201637eeafa5011c69a62b6fea3f36add543 Mon Sep 17 00:00:00 2001 From: Varun-Kolanu Date: Mon, 18 Nov 2024 02:50:07 +0530 Subject: [PATCH] fix: safety feature of disabling maintainers to use the bot disabled for private repos --- README.md | 4 +++- src/handlers/issue_comment.js | 7 +++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2a49a8c..ba39bbe 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,9 @@ See [Contributing guide][contributing] for contributing to the project. ## Note for maintainers: -Assignment and Abandoning of issues doesn't work for users having permissions admin, maintainer or triage, since they already can assign themselves and also to avoid accidental assignment of the issue while explaining a contributor how to claim. +Assignment and Abandoning of issues doesn't work for users having permissions admin, maintainer or triage in public repos, since they already can assign themselves and also to avoid accidental assignment of the issue while explaining a contributor how to claim. + +But the exception is for private repos, since it becomes essential to make a normal contributor too a collaborator to allow them to access the repo and hence this safety feature may interfere with the main functionality. # Usage diff --git a/src/handlers/issue_comment.js b/src/handlers/issue_comment.js index b7f151e..cea7e7c 100644 --- a/src/handlers/issue_comment.js +++ b/src/handlers/issue_comment.js @@ -1,18 +1,17 @@ import { skipCommenters } from "../helpers/skip_commenters.js"; import getAssignedIssues from "../helpers/get_assigned_issues.js"; import { issueOrIssues, thisOrThese } from "../helpers/pluralize.js"; -import { getConfig } from "../helpers/config.js"; import { Request, checkRequest } from "../helpers/check_request.js"; import { Assignment, shouldAssign } from "../helpers/should_assign.js"; import { UnAssignment, shouldUnAssign } from "../helpers/should_unassign.js"; export default async function issueCommentHandler() { // Fetching comment - const { comment } = this.context.payload; + const { comment, repository } = this.context.payload; const commenter = comment.user.login; - // If commenter is bot or maintainer. - if (skipCommenters(commenter, this.maintainers)) return; + // If repository is pubic and commenter is bot or maintainer. + if (!repository.private && skipCommenters(commenter, this.maintainers)) return; // Get assignees of the issue const assignees = this.issue.assignees.map(