@@ -17,11 +17,11 @@ check_user() {
1717 PERMISSION=$( echo " $PERM_JSON " | jq -r ' .permission // "none"' )
1818
1919 if [[ " $PERMISSION " =~ ^(admin| write| triage)$ ]]; then
20- echo " [advanced-check] User @$user is core member ($PERMISSION ). Skipping ."
20+ echo " [advanced-check] User @$user is core member ($PERMISSION ). Qualification check skipped ."
2121 return 0
2222 fi
2323
24- # Get counts
24+ # 2. Get counts
2525 GFI_QUERY=" repo:$REPO is:issue is:closed assignee:$user -reason:\" not planned\" label:\" good first issue\" "
2626 INT_QUERY=" repo:$REPO is:issue is:closed assignee:$user -reason:\" not planned\" label:\" intermediate\" "
2727
@@ -32,7 +32,7 @@ check_user() {
3232 if ! [[ " $GFI_COUNT " =~ ^[0-9]+$ ]]; then GFI_COUNT=0; fi
3333 if ! [[ " $INT_COUNT " =~ ^[0-9]+$ ]]; then INT_COUNT=0; fi
3434
35- # Validation Logic
35+ # 3. Validation Logic
3636 if (( GFI_COUNT >= 1 )) && (( INT_COUNT >= 1 )) ; then
3737 echo " [advanced-check] User @$user qualified."
3838 return 0
@@ -47,7 +47,6 @@ check_user() {
4747 fi
4848
4949 # Post the message FIRST, then unassign.
50- # This ensures the user sees the explanation even if the unassign call has issues.
5150 MSG=" Hi @$user , I cannot assign you to this issue yet.
5251
5352**Why?**
@@ -72,10 +71,19 @@ if [[ -n "${TRIGGER_ASSIGNEE:-}" ]]; then
7271 check_user " $TRIGGER_ASSIGNEE "
7372else
7473 log " Checking all current assignees..."
75- # Use process substitution instead of a pipe to avoid subshell issues
76- while read -r user; do
77- if [[ -n " $user " ]]; then
78- check_user " $user "
79- fi
80- done < <( gh issue view " $ISSUE_NUMBER " --repo " $REPO " --json assignees --jq ' .assignees[].login' )
74+
75+ # Fetch assignees into a variable first.
76+ # This ensures 'set -e' catches any API failures here.
77+ ASSIGNEE_LIST=$( gh issue view " $ISSUE_NUMBER " --repo " $REPO " --json assignees --jq ' .assignees[].login' )
78+
79+ if [[ -z " $ASSIGNEE_LIST " ]]; then
80+ log " No assignees found to check."
81+ else
82+ # Use a here-string (<<<) to iterate over the variable safely.
83+ while read -r user; do
84+ if [[ -n " $user " ]]; then
85+ check_user " $user "
86+ fi
87+ done <<< " $ASSIGNEE_LIST"
88+ fi
8189fi
0 commit comments