Skip to content

Commit 4d6aa15

Browse files
committed
add link to PR
1 parent 4fc7d39 commit 4d6aa15

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

scripts/release/__tests__/createReleasePR.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const buildTestCommit = (
1616
message: string;
1717
}> = {}
1818
): string => {
19-
const { type = 'fix', scope, message = 'fix the thing' } = options;
19+
const { type = 'fix', scope, message = 'fix the thing (#123)' } = options;
2020
const baseTestCommit = `b2501882|${gitAuthor.name}|${gitAuthor.email}`;
2121
const typeAndScope = `${type}${scope ? `(${scope})` : ''}`;
2222

@@ -45,6 +45,7 @@ describe('createReleasePR', () => {
4545
hash: 'b2501882',
4646
scope: 'javascript',
4747
message: 'fix(javascript): fix the thing',
48+
prNumber: '123',
4849
raw: testCommit,
4950
type: 'fix',
5051
author: `[${gitAuthor.name}](${gitAuthor.email})`,
@@ -57,6 +58,7 @@ describe('createReleasePR', () => {
5758
hash: 'b2501882',
5859
scope: 'specs',
5960
message: 'fix(specs): fix the thing',
61+
prNumber: '123',
6062
raw: testCommit,
6163
type: 'fix',
6264
author: `[${gitAuthor.name}](${gitAuthor.email})`,

scripts/release/createReleasePR.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ export async function parseCommit(commit: string): Promise<Commit> {
117117
const [hash, authorName, authorEmail, message] = commit.split('|');
118118
const commitScope = message.slice(0, message.indexOf(':'));
119119
const typeAndScope = commitScope.match(/(.+)\((.+)\)/);
120+
const prNumber = message.match(/#(\d+)/);
121+
let commitMessage = message;
122+
123+
if (prNumber) {
124+
commitMessage = message.replace(`(#${prNumber[1]})`, '').trim();
125+
}
120126

121127
// We skip generation commits as they do not appear in changelogs
122128
if (
@@ -159,7 +165,8 @@ export async function parseCommit(commit: string): Promise<Commit> {
159165
hash,
160166
type: typeAndScope[1], // `fix` | `feat` | `chore` | ...
161167
scope, // `clients` | `specs` | `javascript` | `php` | `java` | ...
162-
message,
168+
message: commitMessage,
169+
prNumber: prNumber ? prNumber[1] : undefined,
163170
raw: commit,
164171
author: fetchedUsers[authorEmail],
165172
};
@@ -411,9 +418,18 @@ async function createReleasePR(): Promise<void> {
411418
continue;
412419
}
413420

414-
changelogCommits.push(
415-
`- [${validCommit.hash}](https://github.com/${OWNER}/${REPO}/commit/${validCommit.hash}) ${validCommit.message} by ${validCommit.author}`
416-
);
421+
const changelogCommit = [
422+
`[${validCommit.hash}](https://github.com/${OWNER}/${REPO}/commit/${validCommit.hash})`,
423+
validCommit.message,
424+
validCommit.prNumber
425+
? `([#${validCommit.prNumber}](https://github.com/${OWNER}/${REPO}/pull/${validCommit.prNumber}))`
426+
: undefined,
427+
`by ${validCommit.author}`,
428+
]
429+
.filter(Boolean)
430+
.join(' ');
431+
432+
changelogCommits.push(`- ${changelogCommit}`);
417433
}
418434

419435
return {

scripts/release/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export type PassedCommit = {
2929
author: string;
3030
message: string;
3131
raw: string;
32+
prNumber: string | undefined;
3233
};
3334

3435
export type Commit =

0 commit comments

Comments
 (0)