@@ -42,21 +42,21 @@ repo_name="stdlib"
4242# Label to add/remove for duplicate PRs:
4343duplicate_label=" Potential Duplicate"
4444
45- # Debug mode controlled by environment variable (defaults to false if not set)
45+ # Debug mode controlled by environment variable (defaults to false if not set):
4646debug=" ${DEBUG:- false} "
4747
48- # Configure retries for API calls
48+ # Configure retries for API calls:
4949max_retries=3
5050retry_delay=2
5151
5252
5353# FUNCTIONS #
5454
55- # Debug logging function
55+ # Debug logging function.
5656#
5757# $1 - debug message
5858debug_log () {
59- # Only print debug messages if DEBUG environment variable is set to "true"
59+ # Only print debug messages if DEBUG environment variable is set to "true":
6060 if [ " $debug " = true ]; then
6161 echo " [DEBUG] $1 " >&2
6262 fi
@@ -104,7 +104,7 @@ github_api() {
104104 headers+=(" -H" " Content-Type: application/json" )
105105 fi
106106
107- # Add retry logic
107+ # Add retry logic...
108108 while [ $retry_count -lt $max_retries ] && [ " $success " = false ]; do
109109 if [ $retry_count -gt 0 ]; then
110110 echo " Retrying request (attempt $(( retry_count+ 1 )) /${max_retries} )..."
@@ -118,13 +118,13 @@ github_api() {
118118 response=$( curl -s -w " %{http_code}" -X " ${method} " " ${headers[@]} " " ${github_api_url}${endpoint} " )
119119 fi
120120
121- # Extract status code (last 3 digits) and actual response (everything before)
121+ # Extract status code (last 3 digits) and actual response (everything before):
122122 status_code=" ${response: -3} "
123123 response=" ${response: 0: ${# response} -3} "
124124
125125 debug_log " Status code: $status_code "
126126
127- # Check if we got a successful response
127+ # Check if we got a successful response:
128128 if [[ $status_code -ge 200 && $status_code -lt 300 ]]; then
129129 success=true
130130 else
@@ -138,15 +138,15 @@ github_api() {
138138 return 1
139139 fi
140140
141- # Validate that response is valid JSON if expected
141+ # Validate that response is valid JSON if expected:
142142 if ! echo " $response " | jq -e ' .' > /dev/null 2>&1 ; then
143143 echo " Warning: Response is not valid JSON: ${response} " >&2
144- # Return empty JSON object as fallback
144+ # Return empty JSON object as fallback:
145145 echo " {}"
146146 return 0
147147 fi
148148
149- # Return the actual response data (without status code)
149+ # Return the actual response data (without status code):
150150 echo " $response "
151151 return 0
152152}
@@ -159,7 +159,7 @@ extract_resolved_issues() {
159159
160160 debug_log " Extracting resolved issues from PR body of length ${# body} chars"
161161
162- # Handle empty body case
162+ # Handle empty body case:
163163 if [ -z " $body " ]; then
164164 debug_log " PR body is empty, no issues to extract"
165165 return 0
@@ -192,7 +192,7 @@ remove_label() {
192192main () {
193193 echo " Fetching open pull requests..."
194194
195- # Get all open PRs with pagination:
195+ # Get all open PRs with pagination...
196196 open_prs=" []"
197197 page=1
198198
@@ -209,7 +209,7 @@ main() {
209209 debug_log " Got $page_count PRs on page $page "
210210
211211 if [ " $page_count " -eq 0 ]; then
212- # No more results, break the loop
212+ # No more results, break the loop:
213213 debug_log " No more PRs, breaking pagination loop"
214214 break
215215 fi
@@ -236,7 +236,7 @@ main() {
236236 declare -a issue_prs_values
237237 declare -a labeled_prs_list
238238
239- # Get all issues with the duplicate label in one API call
239+ # Get all issues with the duplicate label in one API call:
240240 echo " Fetching PRs with duplicate label..."
241241 encoded_label=${duplicate_label// /% 20}
242242 labeled_prs_data=$( github_api " GET" " /repos/${repo_owner} /${repo_name} /issues?labels=${encoded_label} &state=open&per_page=100" )
@@ -253,7 +253,7 @@ main() {
253253 fi
254254 echo " Found ${# labeled_prs_list[@]} PRs with duplicate label"
255255
256- # Process each PR to build issue mappings:
256+ # Process each PR to build issue mappings...
257257 echo " Processing PRs for issue references..."
258258 debug_log " Starting to process $total_prs PRs for issue references"
259259
@@ -285,7 +285,7 @@ main() {
285285
286286 for issue in $resolved_issues ; do
287287 debug_log " PR #$pr_number references issue #$issue "
288- # Find existing issue index
288+ # Find existing issue index:
289289 index=-1
290290 for j in " ${! issue_prs_keys[@]} " ; do
291291 if [ " ${issue_prs_keys[$j]} " = " $issue " ]; then
@@ -307,7 +307,7 @@ main() {
307307 debug_log " Finished processing all PRs for issue references"
308308 debug_log " Found ${# issue_prs_keys[@]} unique issues referenced in PRs"
309309
310- # Process the mappings to find duplicates:
310+ # Process the mappings to find duplicates...
311311 declare -a should_be_labeled_list
312312
313313 for i in " ${! issue_prs_keys[@]} " ; do
0 commit comments