Skip to content

Commit e925c36

Browse files
authored
fix: update .github/scripts/bot-advanced-check.sh to unassign unqualified users (hiero-ledger#1602)
Signed-off-by: MontyPokemon <[email protected]>
1 parent 513e8e3 commit e925c36

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

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

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,26 +89,20 @@ get_intermediate_count() {
8989
already_commented() {
9090
local user=$1
9191
local marker="$COMMENT_MARKER_PREFIX @$user"
92-
9392
gh issue view "$ISSUE_NUMBER" --repo "$REPO" \
9493
--json comments \
95-
--jq --arg marker "$marker" '
96-
.comments[].body
97-
| select(contains($marker))
98-
' | grep -q .
94+
--jq '.comments[].body' | grep -Fq "$marker"
9995
}
10096

10197
#######################################
10298
# Helper: is user currently assigned?
10399
#######################################
100+
104101
is_assigned() {
105102
local user=$1
106-
107103
gh issue view "$ISSUE_NUMBER" --repo "$REPO" \
108104
--json assignees \
109-
--jq --arg user "$user" '
110-
.assignees[].login | select(. == $user)
111-
' | grep -q .
105+
--jq '.assignees[].login' | grep -Fxq "$user"
112106
}
113107

114108
#######################################
@@ -215,8 +209,20 @@ $COMMENT_MARKER_PREFIX @$user"
215209
fi
216210

217211
if is_assigned "$user"; then
218-
log "Unassigning @$user."
219-
gh issue edit "$ISSUE_NUMBER" --repo "$REPO" --remove-assignee "$user"
212+
log "Unassigning @$user ..."
213+
json_body="{\"assignees\": [\"$user\"]}"
214+
response=$(
215+
gh api \
216+
--method DELETE \
217+
"repos/$REPO/issues/$ISSUE_NUMBER/assignees" \
218+
--input <(echo "$json_body") \
219+
|| echo "error"
220+
)
221+
if [[ "$response" != "error" ]]; then
222+
log "Successfully unassigned @$user."
223+
else
224+
log "Failed to unassign @$user."
225+
fi
220226
else
221227
log "User @$user already unassigned. Skipping."
222228
fi
@@ -248,4 +254,4 @@ else
248254
while read -r user; do
249255
[[ -n "$user" ]] && check_user "$user"
250256
done <<< "$ASSIGNEES"
251-
fi
257+
fi

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
248248
- Fixed bot-pr-missing-linked-issue to skip commenting on pull requests created by automated bots. (#1382)
249249
- Updated `.github/scripts/bot-community-calls.sh` to skip posting reminders on issues created by bot accounts. (#1383)
250250
- Fixed incorrect run instructions and broaden error handling in `token_dissociate_transaction.py` example to improve usability for new users (#1468)
251+
- Update `.github/scripts/bot-advanced-check.sh` to unassign unqualified users.
251252

252253
### Removed
253254

0 commit comments

Comments
 (0)