Skip to content

Commit b35c178

Browse files
committed
fix(scripts): correctly check for release commit
1 parent 388098d commit b35c178

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

scripts/ci/codegen/pushGeneratedCode.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ensureGitHubToken, MAIN_BRANCH, run } from '../../common';
33
import { configureGitHubAuthor } from '../../release/common';
44
import { getNbGitDiff } from '../utils';
55

6-
import text from './text';
6+
import text, { commitStartPrepareRelease } from './text';
77

88
const PR_NUMBER = parseInt(process.env.PR_NUMBER || '0', 10);
99

@@ -25,7 +25,7 @@ export async function pushGeneratedCode(): Promise<void> {
2525
const baseBranch = await run('git branch --show-current');
2626
const isMainBranch = baseBranch === MAIN_BRANCH;
2727
const IS_RELEASE_COMMIT = (await run('git log -1 --format="%s"')).startsWith(
28-
text.commitPrepareReleaseMessage
28+
commitStartPrepareRelease
2929
);
3030
console.log(`Checking codegen status on '${baseBranch}'.`);
3131

scripts/ci/codegen/spreadGeneration.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import {
1919
import type { Language } from '../../types';
2020
import { getNbGitDiff } from '../utils';
2121

22-
import text from './text';
22+
import text, { commitStartRelease } from './text';
2323

2424
export function decideWhereToSpread(commitMessage: string): Language[] {
25-
if (commitMessage.startsWith(text.commitReleaseMessage)) {
25+
if (commitMessage.startsWith(commitStartRelease)) {
2626
return LANGUAGES;
2727
}
2828

@@ -40,7 +40,7 @@ export function cleanUpCommitMessage(
4040
commitMessage: string,
4141
version: string
4242
): string {
43-
if (commitMessage.startsWith(text.commitReleaseMessage)) {
43+
if (commitMessage.startsWith(commitStartRelease)) {
4444
return `chore: release ${version}`;
4545
}
4646

@@ -86,9 +86,7 @@ async function spreadGeneration(): Promise<void> {
8686
.map((coAuthor) => coAuthor.trim())
8787
.filter(Boolean);
8888

89-
const IS_RELEASE_COMMIT = lastCommitMessage.startsWith(
90-
text.commitReleaseMessage
91-
);
89+
const IS_RELEASE_COMMIT = lastCommitMessage.startsWith(commitStartRelease);
9290
const langs = decideWhereToSpread(lastCommitMessage);
9391
console.log(
9492
'Spreading code to the following repositories:',

scripts/ci/codegen/text.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { MAIN_BRANCH, REPO_URL, TODAY } from '../../common';
22

3+
export const commitStartPrepareRelease = 'chore: prepare release';
4+
export const commitStartRelease = 'chore: release';
5+
36
export default {
47
commitStartMessage: 'chore: generated code for commit',
5-
commitPrepareReleaseMessage: `chore: prepare release ${TODAY}`,
6-
commitReleaseMessage: `chore: release ${TODAY}`,
8+
commitPrepareReleaseMessage: `${commitStartPrepareRelease} ${TODAY}`,
9+
commitReleaseMessage: `${commitStartRelease} ${TODAY}`,
710
notification: {
811
header: '### 🔨 The codegen job will run at the end of the CI.',
912
body: (): string =>

0 commit comments

Comments
 (0)