Skip to content

Commit f0f86ea

Browse files
committed
feat: increase maximum concurrent issue assignments to 3 and update validation logic
1 parent d28919b commit f0f86ea

3 files changed

Lines changed: 22 additions & 20 deletions

File tree

.github/scripts/issue-management/assign-handler.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
async function findExistingAssignment(github, owner, repo, username, currentIssueNumber) {
1+
async function findExistingAssignments(github, owner, repo, username, currentIssueNumber) {
22
const { data: issues } = await github.rest.issues.listForRepo({
33
owner,
44
repo,
@@ -7,13 +7,11 @@ async function findExistingAssignment(github, owner, repo, username, currentIssu
77
per_page: 100,
88
});
99

10-
const assignedIssues = issues.filter(
11-
(issue) => !issue.pull_request && issue.number !== currentIssueNumber
12-
);
13-
14-
return assignedIssues.length > 0 ? assignedIssues[0] : null;
10+
return issues.filter((issue) => !issue.pull_request && issue.number !== currentIssueNumber);
1511
}
1612

13+
const MAX_ASSIGNED_ISSUES = 3;
14+
1715
async function handleAssign({ github, context, username, hasWriteAccess }) {
1816
const { owner, repo } = context.repo;
1917
const issueNumber = context.payload.issue.number;
@@ -77,13 +75,16 @@ async function handleAssign({ github, context, username, hasWriteAccess }) {
7775
return;
7876
}
7977

80-
const existingIssue = await findExistingAssignment(github, owner, repo, username, issueNumber);
81-
if (existingIssue) {
78+
const existingIssues = await findExistingAssignments(github, owner, repo, username, issueNumber);
79+
if (existingIssues.length >= MAX_ASSIGNED_ISSUES) {
80+
const issueList = existingIssues
81+
.map((i) => `> 📋 [#${i.number}${i.title}](${i.html_url})`)
82+
.join('\n');
8283
await github.rest.issues.createComment({
8384
owner,
8485
repo,
8586
issue_number: issueNumber,
86-
body: `❌ @${username} already has an active assigned issue.\nPlease complete or unassign the current issue first.\n\n> 📋 Active issue: [#${existingIssue.number}${existingIssue.title}](${existingIssue.html_url})`,
87+
body: `❌ @${username} already has **${existingIssues.length}/${MAX_ASSIGNED_ISSUES}** active assigned issues (the maximum allowed).\nPlease complete or unassign one of their current issues first.\n\n${issueList}`,
8788
});
8889
return;
8990
}

.github/scripts/issue-management/claim-handler.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
async function findExistingAssignment(github, owner, repo, username, currentIssueNumber) {
1+
async function findExistingAssignments(github, owner, repo, username, currentIssueNumber) {
22
const { data: issues } = await github.rest.issues.listForRepo({
33
owner,
44
repo,
@@ -7,13 +7,11 @@ async function findExistingAssignment(github, owner, repo, username, currentIssu
77
per_page: 100,
88
});
99

10-
const assignedIssues = issues.filter(
11-
(issue) => !issue.pull_request && issue.number !== currentIssueNumber
12-
);
13-
14-
return assignedIssues.length > 0 ? assignedIssues[0] : null;
10+
return issues.filter((issue) => !issue.pull_request && issue.number !== currentIssueNumber);
1511
}
1612

13+
const MAX_ASSIGNED_ISSUES = 3;
14+
1715
async function handleClaim({ github, context }) {
1816
const { owner, repo } = context.repo;
1917
const issueNumber = context.payload.issue.number;
@@ -64,13 +62,16 @@ async function handleClaim({ github, context }) {
6462
return;
6563
}
6664

67-
const existingIssue = await findExistingAssignment(github, owner, repo, commenter, issueNumber);
68-
if (existingIssue) {
65+
const existingIssues = await findExistingAssignments(github, owner, repo, commenter, issueNumber);
66+
if (existingIssues.length >= MAX_ASSIGNED_ISSUES) {
67+
const issueList = existingIssues
68+
.map((i) => `> 📋 [#${i.number}${i.title}](${i.html_url})`)
69+
.join('\n');
6970
await github.rest.issues.createComment({
7071
owner,
7172
repo,
7273
issue_number: issueNumber,
73-
body: `❌ You already have an active assigned issue.\nPlease complete or unassign your current issue first.\n\n> 📋 Active issue: [#${existingIssue.number}${existingIssue.title}](${existingIssue.html_url})`,
74+
body: `❌ You already have **${existingIssues.length}/${MAX_ASSIGNED_ISSUES}** active assigned issues (the maximum allowed).\nPlease complete or unassign one of your current issues before claiming another.\n\n${issueList}`,
7475
});
7576
return;
7677
}

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ The accuracy engine lives in `utils/time.ts` and `lib/calculate.ts`.
153153
CommitPulse uses a custom, lightweight **GitHub Actions** automation system to manage issues fairly. This ensures that everyone (especially during events like **GSSoC**) gets a chance to contribute and prevents "issue hoarding".
154154

155155
> [!IMPORTANT]
156-
> **The Golden Rule:** You can only be assigned to **ONE** open issue at a time. Finish it or unassign yourself before claiming another.
156+
> **The Golden Rule:** You can be assigned to a maximum of **3** open issues at a time. Complete or unassign yourself from one before claiming more.
157157
158158
### 📋 Structured Issue Templates
159159

@@ -205,7 +205,7 @@ To keep the project moving, assignments are not permanent.
205205
If the bot rejects your command, check these common scenarios:
206206

207207
- **"Commands cannot be used on closed issues"**: You cannot claim, assign, or unassign on closed issues. Find an open one!
208-
- **"You already have an active assigned issue"**: You must finish your current task. If you're stuck, ask a maintainer to `/unassign` you from the old one.
208+
- **"You already have X/3 active assigned issues"**: You have reached the maximum of 3 concurrent assignments. Finish one of your current tasks before claiming a new issue. If you're stuck, ask a maintainer to `/unassign` you from one.
209209
- **"This issue is already assigned to @username"**: Be faster next time! Look for issues without assignees.
210210
- **"Only the author of this issue can claim it"**: You tried to `/claim` an issue you did not create. You can only claim issues that you authored.
211211
- **"The following label(s) do not exist"**: You can only add existing repo labels. The bot will reply with a list of valid labels you can use.

0 commit comments

Comments
 (0)