@@ -125,8 +125,8 @@ get_issue_title() {
125125
126126 # Try to get issue title from GitHub API
127127 local title=$( gh api " repos/$repo /issues/$issue_number " --jq ' .title' 2> /dev/null || echo " " )
128- if [[ -n " $title " ]]; then
129- echo " Issue # $issue_number : $title "
128+ if [[ -n " $title " && " $title " != " null " && ! " $title " =~ " message.*Not Found " ]]; then
129+ echo " $title "
130130 else
131131 echo " Issue #$issue_number "
132132 fi
@@ -136,7 +136,8 @@ get_issue_title() {
136136extract_issue_numbers () {
137137 local commit_msg=" $1 "
138138 # Extract issue numbers from various formats: #123, (refs #123), (refs #123 #456)
139- echo " $commit_msg " | grep -o ' #[0-9]*' | sort -u | tr ' \n' ' '
139+ # Return each number on a separate line to avoid concatenation
140+ echo " $commit_msg " | grep -o ' #[0-9]*' | sed ' s/#//' | sort -u
140141}
141142
142143# Function to generate release notes
@@ -181,21 +182,24 @@ generate_release_notes() {
181182
182183 if [[ -n " $issue_numbers " ]]; then
183184 # Commit has issue references
184- for issue_num in $issue_numbers ; do
185- # Remove # prefix for processing and clean up
186- local clean_issue_num=${issue_num# \# }
187- clean_issue_num=$( echo " $clean_issue_num " | tr -d ' ' )
188-
189- # Only process if it's a valid number
190- if [[ " $clean_issue_num " =~ ^[0-9]+$ ]]; then
191- issue_commits[" $clean_issue_num " ]+=" $commit " $' \n '
185+ while IFS= read -r issue_num; do
186+ if [[ -n " $issue_num " ]]; then
187+ # Clean up the issue number
188+ local clean_issue_num=$( echo " $issue_num " | tr -d ' ' )
192189
193- # Get issue title if not already cached
194- if [[ -z " ${issue_titles[$clean_issue_num]} " ]]; then
195- issue_titles[" $clean_issue_num " ]=$( get_issue_title " $clean_issue_num " )
190+ # Only process if it's a valid number
191+ if [[ " $clean_issue_num " =~ ^[0-9]+$ ]]; then
192+ # Ensure clean key without quotes
193+ local key=" $clean_issue_num "
194+ issue_commits[$key ]+=" $commit " $' \n '
195+
196+ # Get issue title if not already cached
197+ if [[ -z " ${issue_titles[$key]} " ]]; then
198+ issue_titles[$key ]=$( get_issue_title " $clean_issue_num " )
199+ fi
196200 fi
197201 fi
198- done
202+ done <<< " $issue_numbers "
199203 else
200204 # Commit has no issue references
201205 other_commits+=(" $commit " )
@@ -232,10 +236,12 @@ EOF
232236 for issue_num in $sorted_issues ; do
233237 local title=" ${issue_titles[$issue_num]} "
234238
235- # If title is in the format 'Issue #n: Title', use it; otherwise, fallback
236- if [[ " $title " =~ ^Issue\ # [0-9]+: ]]; then
239+ # Format the header properly
240+ if [[ " $title " =~ ^Issue\ # [0-9]+$ ]]; then
241+ # Fallback format when no title was found
237242 local header= " $title "
238243 else
244+ # Use the actual title from GitHub API
239245 local header= " Issue #$issue_num : $title "
240246 fi
241247
0 commit comments