Skip to content

Commit dd4295e

Browse files
AkshayKumarSahuCopilotcoderabbitai[bot]
authored
chore: Check triage members max assignment is protected from being a mentor (hiero-ledger#1811)
Signed-off-by: AkshayKumarSahu <akshaykumar15031999@gmail.com> Signed-off-by: Akshay Kumar <akshaykumar15031999@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent de7d2b7 commit dd4295e

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

.github/scripts/bot-assignment-check.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,26 @@ issue_has_gfi() {
3535
[[ "$has" == "true" ]]
3636
}
3737

38+
# Count open assignments for a user
39+
# For triage users (mentors), excludes issues with 'mentor-duty' label
40+
# This allows mentors to be assigned to mentorship issues without consuming their assignment limit
3841
assignments_count() {
39-
gh issue list --repo "${REPO}" --assignee "${ASSIGNEE}" --state open --limit 100 --json number --jq 'length'
42+
local permission="${1:-none}"
43+
44+
if [[ "$permission" == "triage" ]]; then
45+
echo "Triage user detected — excluding mentor-duty issues from count." >&2
46+
# For triage users, exclude issues with 'mentor-duty' label
47+
gh api "repos/${REPO}/issues?per_page=100&page=1" \
48+
-f assignee="${ASSIGNEE}" \
49+
-f state=open \
50+
--jq '.[]
51+
| select(.pull_request == null)
52+
| select(any(.labels[]; .name == "mentor-duty") | not)
53+
| .number' | grep -c . || echo 0
54+
else
55+
# For non-triage users, count all open assignments
56+
gh issue list --repo "${REPO}" --assignee "${ASSIGNEE}" --state open --limit 100 --json number --jq 'length'
57+
fi
4058
}
4159

4260
remove_assignee() {
@@ -118,7 +136,7 @@ if is_spam_user; then
118136
echo "User is in spam list. Applying restricted assignment rules."
119137
fi
120138

121-
COUNT="$(assignments_count)"
139+
COUNT="$(assignments_count "$PERMISSION")"
122140

123141
# Apply assignment rules
124142
if [[ "$SPAM" == "true" ]]; then

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
2929
- Format `tests/unit/endpoint_test.py` using black. (`#1792`)
3030

3131
### .github
32+
- Added triage members max assignment is protected from being a mentor in `.github/scripts/bot-assignment-check.sh`. (#1718)
3233
- Revert PythonBot workflow to restore previous stable behavior. (#1825)
3334
- Added GitHub Actions workflow to remind draft PR authors to mark ready for review after pushing changes. (#1722)
3435
- Fixed bot workflow runtime failure caused by strict `FAILED_WORKFLOW_NAME` validation. (`#1690`)

0 commit comments

Comments
 (0)