@@ -113,14 +113,15 @@ export function getSkippedCommitsText({
113
113
}
114
114
115
115
export async function parseCommit ( commit : string ) : Promise < Commit > {
116
- const [ hash , authorName , authorEmail , message ] = commit . split ( '|' ) ;
116
+ const [ hash , authorEmail , message ] = commit . split ( '|' ) ;
117
117
const commitScope = message . slice ( 0 , message . indexOf ( ':' ) ) ;
118
118
const typeAndScope = commitScope . match ( / ( .+ ) \( ( .+ ) \) / ) ;
119
- const prNumber = message . match ( / # ( \d + ) / ) ;
119
+ const prNumberMatch = message . match ( / # ( \d + ) / ) ;
120
+ const prNumber = prNumberMatch ? parseInt ( prNumberMatch [ 1 ] , 10 ) : 0 ;
120
121
let commitMessage = message ;
121
122
122
123
if ( prNumber ) {
123
- commitMessage = message . replace ( `(#${ prNumber [ 1 ] } )` , '' ) . trim ( ) ;
124
+ commitMessage = message . replace ( `(#${ prNumber } )` , '' ) . trim ( ) ;
124
125
}
125
126
126
127
// We skip generation commits as they do not appear in changelogs
@@ -146,18 +147,18 @@ export async function parseCommit(commit: string): Promise<Commit> {
146
147
}
147
148
148
149
// Retrieve the author GitHub username if publicly available
149
- if ( ! fetchedUsers [ authorEmail ] ) {
150
+ if ( ! fetchedUsers [ authorEmail ] && prNumber ) {
150
151
const octokit = getOctokit ( ) ;
151
- const { data } = await octokit . search . users ( {
152
- q : authorEmail ,
152
+ const { data } = await octokit . pulls . get ( {
153
+ owner : OWNER ,
154
+ repo : REPO ,
155
+ pull_number : prNumber ,
153
156
} ) ;
154
157
155
- if ( data . total_count === 0 ) {
156
- fetchedUsers [ authorEmail ] = `[${ authorName } ](${ authorEmail } )` ;
157
- } else {
158
+ if ( data . user ) {
158
159
fetchedUsers [
159
160
authorEmail
160
- ] = `[@${ data . items [ 0 ] . login } ](https://github.com/${ data . items [ 0 ] . login } /)` ;
161
+ ] = `[@${ data . user . login } ](https://github.com/${ data . user . login } /)` ;
161
162
}
162
163
}
163
164
@@ -166,7 +167,7 @@ export async function parseCommit(commit: string): Promise<Commit> {
166
167
type : typeAndScope [ 1 ] , // `fix` | `feat` | `chore` | ...
167
168
scope, // `clients` | `specs` | `javascript` | `php` | `java` | ...
168
169
message : commitMessage ,
169
- prNumber : prNumber ? prNumber [ 1 ] : undefined ,
170
+ prNumber,
170
171
raw : commit ,
171
172
author : fetchedUsers [ authorEmail ] ,
172
173
} ;
@@ -298,7 +299,7 @@ async function getCommits(): Promise<{
298
299
// Reading commits since last release
299
300
const latestCommits = (
300
301
await run (
301
- `git log --pretty=format:"%h|%an|% ae|%s" ${ RELEASED_TAG } ..${ MAIN_BRANCH } `
302
+ `git log --pretty=format:"%h|%ae|%s" ${ RELEASED_TAG } ..${ MAIN_BRANCH } `
302
303
)
303
304
)
304
305
. split ( '\n' )
0 commit comments