@@ -166,7 +166,7 @@ extract_resolved_issues() {
166
166
fi
167
167
168
168
local issues
169
- issues=$( echo " $body " | grep -Eio " (resolves|closes|close|fix|fixes|fixed|resolve)[[:space:]]*(#[0-9]+|https?://github\.com/stdlib-js/stdlib /issues/[0-9]+)" |
169
+ issues=$( echo " $body " | grep -Eio " (resolves|closes|close|fix|fixes|fixed|resolve)[[:space:]]*(#[0-9]+|https?://github\.com/${repo_owner} / ${repo_name} /issues/[0-9]+)" |
170
170
grep -Eo " ([0-9]+)$" | sort -u)
171
171
172
172
debug_log " Extracted issues: $issues "
@@ -181,7 +181,11 @@ remove_label() {
181
181
local pr_number=" $1 "
182
182
local label=" $2 "
183
183
184
- github_api " DELETE" " /repos/${repo_owner} /${repo_name} /issues/${pr_number} /labels/${label} " || true
184
+ # URL encode the label name by replacing spaces with %20:
185
+ local encoded_label=" ${label// /% 20} "
186
+
187
+ debug_log " Removing label '${label} ' from PR #${pr_number} "
188
+ github_api " DELETE" " /repos/${repo_owner} /${repo_name} /issues/${pr_number} /labels/${encoded_label} "
185
189
}
186
190
187
191
# Main execution sequence.
@@ -218,14 +222,14 @@ main() {
218
222
done
219
223
220
224
# Check if we found any PRs:
221
- pr_count =$( echo " $open_prs " | jq length)
222
- if [ " $pr_count " -eq 0 ]; then
225
+ total_prs =$( echo " $open_prs " | jq length)
226
+ if [ " $total_prs " -eq 0 ]; then
223
227
echo " No open pull requests found."
224
228
print_success
225
229
exit 0
226
230
fi
227
231
228
- echo " Found ${pr_count } open pull requests."
232
+ echo " Found ${total_prs } open pull requests."
229
233
230
234
# Create arrays to store mappings and track labeled PRs:
231
235
declare -a issue_prs_keys
@@ -251,11 +255,10 @@ main() {
251
255
252
256
# Process each PR to build issue mappings:
253
257
echo " Processing PRs for issue references..."
254
- debug_log " Starting to process $pr_count PRs for issue references"
258
+ debug_log " Starting to process $total_prs PRs for issue references"
255
259
256
260
# Process PRs one by one...
257
- pr_count=0
258
- total_prs=$( echo " $open_prs " | jq length)
261
+ processed_count=0
259
262
260
263
for (( i= 0 ; i< total_prs; i++ )) ; do
261
264
pr=$( echo " $open_prs " | jq -c " .[$i ]" )
@@ -275,9 +278,9 @@ main() {
275
278
pr_body=$( echo " $pr " | jq -r ' .body // ""' )
276
279
resolved_issues=$( extract_resolved_issues " $pr_body " )
277
280
278
- pr_count =$(( pr_count + 1 ))
279
- if [ $(( pr_count % 50 )) -eq 0 ]; then
280
- echo " Processed ${pr_count } PRs..."
281
+ processed_count =$(( processed_count + 1 ))
282
+ if [ $(( processed_count % 50 )) -eq 0 ]; then
283
+ echo " Processed ${processed_count } PRs..."
281
284
fi
282
285
283
286
for issue in $resolved_issues ; do
@@ -317,8 +320,8 @@ main() {
317
320
fi
318
321
done
319
322
320
- debug_log " PRs that should have label: ${should_be_labeled_list[*]} "
321
- debug_log " PRs that currently have label: ${labeled_prs_list[*]} "
323
+ debug_log " PRs that should have label: ${should_be_labeled_list[*]:- none } "
324
+ debug_log " PRs that currently have label: ${labeled_prs_list[*]:- none } "
322
325
323
326
for pr in " ${labeled_prs_list[@]} " ; do
324
327
echo " Checking if PR #${pr} should still have label..."
0 commit comments