Skip to content

Commit 1169230

Browse files
authored
chore(ci): display skipped commits in release issue (#434)
1 parent c6568b5 commit 1169230

File tree

3 files changed

+67
-11
lines changed

3 files changed

+67
-11
lines changed

scripts/release/__tests__/create-release-issue.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
parseCommit,
33
getVersionChangesText,
4+
getSkippedCommitsText,
45
decideReleaseStrategy,
56
readVersions,
67
} from '../create-release-issue';
@@ -247,4 +248,33 @@ describe('create release issue', () => {
247248
expect(versions.java.skipRelease).toBeUndefined();
248249
expect(versions.php.skipRelease).toBeUndefined();
249250
});
251+
252+
it('generates text for skipped commits', () => {
253+
expect(
254+
getSkippedCommitsText({
255+
commitsWithoutLanguageScope: [],
256+
commitsWithUnknownLanguageScope: [],
257+
})
258+
).toMatchInlineSnapshot(`"_(None)_"`);
259+
260+
expect(
261+
getSkippedCommitsText({
262+
commitsWithoutLanguageScope: ['abcdefg fix: something'],
263+
commitsWithUnknownLanguageScope: ['abcdef2 fix(pascal): what'],
264+
})
265+
).toMatchInlineSnapshot(`
266+
"<p></p>
267+
<p>It doesn't mean these commits are being excluded from the release. It means they're not taken into account when the release process figured out the next version number, and updated the changelog.</p>
268+
269+
<p>Commits without language scope:</p>
270+
<ul>
271+
<li>abcdefg fix: something</li>
272+
</ul>
273+
274+
<p>Commits with unknown language scope:</p>
275+
<ul>
276+
<li>abcdef2 fix(pascal): what</li>
277+
</ul>"
278+
`);
279+
});
250280
});

scripts/release/create-release-issue.ts

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,34 @@ export function getVersionChangesText(versions: Versions): string {
5959
}).join('\n');
6060
}
6161

62+
export function getSkippedCommitsText({
63+
commitsWithoutLanguageScope,
64+
commitsWithUnknownLanguageScope,
65+
}: {
66+
commitsWithoutLanguageScope: string[];
67+
commitsWithUnknownLanguageScope: string[];
68+
}): string {
69+
if (
70+
commitsWithoutLanguageScope.length === 0 &&
71+
commitsWithUnknownLanguageScope.length === 0
72+
) {
73+
return '_(None)_';
74+
}
75+
76+
return `<p></p>
77+
<p>${TEXT.skippedCommitsDesc}</p>
78+
79+
<p>Commits without language scope:</p>
80+
<ul>
81+
${commitsWithoutLanguageScope.map((commit) => `<li>${commit}</li>`)}
82+
</ul>
83+
84+
<p>Commits with unknown language scope:</p>
85+
<ul>
86+
${commitsWithUnknownLanguageScope.map((commit) => `<li>${commit}</li>`)}
87+
</ul>`;
88+
}
89+
6290
export function parseCommit(commit: string): Commit {
6391
const LENGTH_SHA1 = 8;
6492
const hash = commit.slice(0, LENGTH_SHA1);
@@ -217,24 +245,18 @@ async function createReleaseIssue(): Promise<void> {
217245
})
218246
.filter(Boolean) as PassedCommit[];
219247

220-
console.log('[INFO] Skipping these commits due to lack of language scope:');
221-
console.log(
222-
commitsWithoutLanguageScope.map((commit) => ` ${commit}`).join('\n')
223-
);
224-
225-
console.log('');
226-
console.log('[INFO] Skipping these commits due to unknown language scope:');
227-
console.log(
228-
commitsWithUnknownLanguageScope.map((commit) => ` ${commit}`).join('\n')
229-
);
230-
231248
const versions = decideReleaseStrategy({
232249
versions: readVersions(),
233250
commits: latestCommits,
234251
});
235252

236253
const versionChanges = getVersionChangesText(versions);
237254

255+
const skippedCommits = getSkippedCommitsText({
256+
commitsWithoutLanguageScope,
257+
commitsWithUnknownLanguageScope,
258+
});
259+
238260
const changelogs = LANGUAGES.filter(
239261
(lang) => !versions[lang].noCommit && versions[lang].current
240262
)
@@ -256,6 +278,8 @@ async function createReleaseIssue(): Promise<void> {
256278
TEXT.header,
257279
TEXT.versionChangeHeader,
258280
versionChanges,
281+
TEXT.skippedCommitsHeader,
282+
skippedCommits,
259283
TEXT.descriptionVersionChanges,
260284
TEXT.indenpendentVersioning,
261285
TEXT.changelogHeader,

scripts/release/text.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ export default {
22
header: `## Summary`,
33

44
versionChangeHeader: `## Version Changes`,
5+
skippedCommitsHeader: `### Skipped Commits`,
6+
skippedCommitsDesc: `It doesn't mean these commits are being excluded from the release. It means they're not taken into account when the release process figured out the next version number, and updated the changelog.`,
57
noCommit: `no commit`,
68
currentVersionNotFound: `current version not found`,
79
descriptionVersionChanges: [

0 commit comments

Comments
 (0)