Skip to content

Commit 5b71a7c

Browse files
committed
build: minor clean-up and encode spaces
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: passed - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 56cc036 commit 5b71a7c

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

.github/workflows/scripts/check_duplicate_prs

+16-13
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ extract_resolved_issues() {
166166
fi
167167

168168
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]+)" |
170170
grep -Eo "([0-9]+)$" | sort -u)
171171

172172
debug_log "Extracted issues: $issues"
@@ -181,7 +181,11 @@ remove_label() {
181181
local pr_number="$1"
182182
local label="$2"
183183

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}"
185189
}
186190

187191
# Main execution sequence.
@@ -218,14 +222,14 @@ main() {
218222
done
219223

220224
# 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
223227
echo "No open pull requests found."
224228
print_success
225229
exit 0
226230
fi
227231

228-
echo "Found ${pr_count} open pull requests."
232+
echo "Found ${total_prs} open pull requests."
229233

230234
# Create arrays to store mappings and track labeled PRs:
231235
declare -a issue_prs_keys
@@ -251,11 +255,10 @@ main() {
251255

252256
# Process each PR to build issue mappings:
253257
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"
255259

256260
# Process PRs one by one...
257-
pr_count=0
258-
total_prs=$(echo "$open_prs" | jq length)
261+
processed_count=0
259262

260263
for ((i=0; i<total_prs; i++)); do
261264
pr=$(echo "$open_prs" | jq -c ".[$i]")
@@ -275,9 +278,9 @@ main() {
275278
pr_body=$(echo "$pr" | jq -r '.body // ""')
276279
resolved_issues=$(extract_resolved_issues "$pr_body")
277280

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..."
281284
fi
282285

283286
for issue in $resolved_issues; do
@@ -317,8 +320,8 @@ main() {
317320
fi
318321
done
319322

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}"
322325

323326
for pr in "${labeled_prs_list[@]}"; do
324327
echo "Checking if PR #${pr} should still have label..."

0 commit comments

Comments
 (0)