@@ -45,11 +45,16 @@ def query-prs [
4545
4646 let query = $query_parts | str join ' '
4747
48- (gh -- repo $repo pr list -- state merged
49- --limit (inf | into int )
50- --json author ,title ,number ,mergedAt ,url ,body ,labels
51- --search $query )
52- | from json
48+ let results = (
49+ gh -- repo $repo pr list -- state merged
50+ --limit (inf | into int )
51+ --json author ,title ,number ,mergedAt ,url ,body ,labels
52+ --search $query
53+ | from json
54+ )
55+
56+ assert ($results | is-not-empty ) " Query returned no results"
57+ $results
5358}
5459
5560# Generate the release notes for the specified version.
@@ -148,11 +153,9 @@ export def write-toc [file: path] {
148153 | each {|header |
149154 let indent = ' - ' | fill - w ($header.level * 2 ) - a right
150155
151- let text = $header.line | str trim - l - c ' #' | str trim - l
152- let text = if $text ends-with $toc {
153- $text | str substring ..< (-1 * ($toc | str length )) | str trim - r
154- } else {
155- $text
156+ mut text = $header.line | str trim - l - c ' #' | str trim - l
157+ if $text ends-with $toc {
158+ $text = $text | str substring ..< (-1 * ($toc | str length )) | str trim - r
156159 }
157160
158161 let link = (
@@ -161,6 +164,22 @@ export def write-toc [file: path] {
161164 | str kebab-case
162165 )
163166
167+ # remove PR link from header, if applicable
168+ let regex = r#' (?x) # verbose mode
169+ (?<text>.+?) # the actual header text
170+ \s+
171+ \( # start PR link
172+ \[\#\d+\] # PR number component
173+ (?: # optional non-capturing group
174+ \(.+?\) # link to PR
175+ )? # end group
176+ \)
177+ '#
178+ let prlink = $text | parse - r $regex
179+ if ($prlink | is-not-empty ) {
180+ $text = $prlink.0.text
181+ }
182+
164183 $" ($indent )[_($text )_]\( #($link )-toc\) "
165184 }
166185 )
0 commit comments