@@ -51,20 +51,44 @@ const needsSeparateARM64Build = package_name => {
5151 ] . includes ( package_name )
5252}
5353
54- const guessReleaseNotes = ( issue ) => {
54+ const guessReleaseNotes = async ( context , issue ) => {
5555 if ( ! issue . pull_request
5656 && issue . labels . filter ( label => label . name === 'component-update' ) . length !== 1 ) throw new Error ( `Cannot determine release note from issue ${ issue . number } ` )
57- let { package_name, version } = guessComponentUpdateDetails ( issue . title )
57+ let { package_name, version } = guessComponentUpdateDetails ( issue . title , issue . body )
5858
5959 package_name = prettyPackageName ( package_name . replace ( / ^ m i n g w - w 6 4 - / , '' ) )
6060
61- const urlMatch = issue . pull_request
62- ? issue . body . match ( / S e e ( h t t p s : \/ \/ \S + ) f o r d e t a i l s / )
63- : issue . body . match ( / (?: ^ | \n ) ( h t t p s : \/ \/ \S + ) $ / )
64- if ( ! urlMatch ) throw new Error ( `Could not determine URL from issue ${ issue . number } ` )
61+ const matchURLInIssue = ( issue ) => {
62+ const match = issue . body . match ( package_name . toLowerCase ( ) === 'bash'
63+ ? / (?: ^ | \n ) ( h t t p s : \/ \/ \S + ) / // for `bash`, use the first URL
64+ : / (?: ^ | \n ) ( h t t p s : \/ \/ \S + ) $ / )
65+ return match && match [ 1 ]
66+ }
67+
68+ const matchURL = async ( ) => {
69+ if ( ! issue . pull_request ) return matchURLInIssue ( issue )
70+
71+ const match = issue . body . match ( / S e e ( h t t p s : \/ \/ \S + ) f o r d e t a i l s / )
72+ if ( match ) return match [ 1 ]
73+
74+ const issueMatch = issue . body . match ( / h t t p s : \/ \/ g i t h u b \. c o m \/ g i t - f o r - w i n d o w s \/ g i t \/ i s s u e s \/ ( \d + ) / )
75+ if ( issueMatch ) {
76+ const githubApiRequest = require ( './github-api-request' )
77+ const issue = await githubApiRequest (
78+ context ,
79+ null ,
80+ 'GET' ,
81+ `/repos/git-for-windows/git/issues/${ issueMatch [ 1 ] } `
82+ )
83+ return matchURLInIssue ( issue )
84+ }
85+ }
86+
87+ const url = await matchURL ( )
88+ if ( ! url ) throw new Error ( `Could not determine URL from issue ${ issue . number } ` )
6589 return {
6690 type : 'feature' ,
67- message : `Comes with [${ package_name } v${ version } ](${ urlMatch [ 1 ] } ).`
91+ message : `Comes with [${ package_name } v${ version } ](${ url } ).`
6892 }
6993}
7094
0 commit comments