@@ -99,28 +99,46 @@ async function getCommitLog(sha) {
99
99
let shortLog = '' ;
100
100
let formattedLog = '' ;
101
101
102
+ const hasGh = await hasGithubCLI ( ) ;
102
103
const rawLog = await execRead ( `
103
104
git log --topo-order --pretty=format:'%s' ${ sha } ...HEAD -- packages/react-devtools*
104
105
` ) ;
105
- rawLog . split ( '\n' ) . forEach ( line => {
106
- line = line . replace ( '[DevTools] ' , '' ) ;
107
-
106
+ const lines = rawLog . split ( '\n' ) ;
107
+ for ( let i = 0 ; i < lines . length ; i ++ ) {
108
+ const line = lines [ i ] . replace ( / ^ \[ d e v t o o l s \] * / i , '' ) ;
108
109
const match = line . match ( / ( .+ ) \( # ( [ 0 - 9 ] + ) \) / ) ;
109
110
if ( match !== null ) {
110
111
const title = match [ 1 ] ;
111
112
const pr = match [ 2 ] ;
112
-
113
- formattedLog += `\n* ${ title } ([USERNAME](https://github.com/USERNAME) in [#${ pr } ](${ PULL_REQUEST_BASE_URL } ${ pr } ))` ;
113
+ let username ;
114
+ if ( hasGh ) {
115
+ const response = await execRead (
116
+ `gh api /repos/facebook/react/pulls/${ pr } `
117
+ ) ;
118
+ const { user} = JSON . parse ( response ) ;
119
+ username = `[${ user . login } ](${ user . html_url } )` ;
120
+ } else {
121
+ username = '[USERNAME](https://github.com/USERNAME)' ;
122
+ }
123
+ formattedLog += `\n* ${ title } (${ username } in [#${ pr } ](${ PULL_REQUEST_BASE_URL } ${ pr } ))` ;
114
124
shortLog += `\n* ${ title } ` ;
115
125
} else {
116
126
formattedLog += `\n* ${ line } ` ;
117
127
shortLog += `\n* ${ line } ` ;
118
128
}
119
- } ) ;
129
+ }
120
130
121
131
return [ shortLog , formattedLog ] ;
122
132
}
123
133
134
+ async function hasGithubCLI ( ) {
135
+ try {
136
+ await exec ( 'which gh' ) ;
137
+ return true ;
138
+ } catch ( _ ) { }
139
+ return false ;
140
+ }
141
+
124
142
async function getPreviousCommitSha ( ) {
125
143
const choices = [ ] ;
126
144
0 commit comments