From b35c178da4479c87da0375d6111f51d4cab9f33c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Thu, 30 Jun 2022 10:36:11 +0200 Subject: [PATCH] fix(scripts): correctly check for release commit --- scripts/ci/codegen/pushGeneratedCode.ts | 4 ++-- scripts/ci/codegen/spreadGeneration.ts | 10 ++++------ scripts/ci/codegen/text.ts | 7 +++++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/ci/codegen/pushGeneratedCode.ts b/scripts/ci/codegen/pushGeneratedCode.ts index 670d054cc2..2add40a958 100644 --- a/scripts/ci/codegen/pushGeneratedCode.ts +++ b/scripts/ci/codegen/pushGeneratedCode.ts @@ -3,7 +3,7 @@ import { ensureGitHubToken, MAIN_BRANCH, run } from '../../common'; import { configureGitHubAuthor } from '../../release/common'; import { getNbGitDiff } from '../utils'; -import text from './text'; +import text, { commitStartPrepareRelease } from './text'; const PR_NUMBER = parseInt(process.env.PR_NUMBER || '0', 10); @@ -25,7 +25,7 @@ export async function pushGeneratedCode(): Promise { const baseBranch = await run('git branch --show-current'); const isMainBranch = baseBranch === MAIN_BRANCH; const IS_RELEASE_COMMIT = (await run('git log -1 --format="%s"')).startsWith( - text.commitPrepareReleaseMessage + commitStartPrepareRelease ); console.log(`Checking codegen status on '${baseBranch}'.`); diff --git a/scripts/ci/codegen/spreadGeneration.ts b/scripts/ci/codegen/spreadGeneration.ts index bb5c8612e2..5c7121e4dc 100644 --- a/scripts/ci/codegen/spreadGeneration.ts +++ b/scripts/ci/codegen/spreadGeneration.ts @@ -19,10 +19,10 @@ import { import type { Language } from '../../types'; import { getNbGitDiff } from '../utils'; -import text from './text'; +import text, { commitStartRelease } from './text'; export function decideWhereToSpread(commitMessage: string): Language[] { - if (commitMessage.startsWith(text.commitReleaseMessage)) { + if (commitMessage.startsWith(commitStartRelease)) { return LANGUAGES; } @@ -40,7 +40,7 @@ export function cleanUpCommitMessage( commitMessage: string, version: string ): string { - if (commitMessage.startsWith(text.commitReleaseMessage)) { + if (commitMessage.startsWith(commitStartRelease)) { return `chore: release ${version}`; } @@ -86,9 +86,7 @@ async function spreadGeneration(): Promise { .map((coAuthor) => coAuthor.trim()) .filter(Boolean); - const IS_RELEASE_COMMIT = lastCommitMessage.startsWith( - text.commitReleaseMessage - ); + const IS_RELEASE_COMMIT = lastCommitMessage.startsWith(commitStartRelease); const langs = decideWhereToSpread(lastCommitMessage); console.log( 'Spreading code to the following repositories:', diff --git a/scripts/ci/codegen/text.ts b/scripts/ci/codegen/text.ts index 1a373d2476..26ee1ea9f4 100644 --- a/scripts/ci/codegen/text.ts +++ b/scripts/ci/codegen/text.ts @@ -1,9 +1,12 @@ import { MAIN_BRANCH, REPO_URL, TODAY } from '../../common'; +export const commitStartPrepareRelease = 'chore: prepare release'; +export const commitStartRelease = 'chore: release'; + export default { commitStartMessage: 'chore: generated code for commit', - commitPrepareReleaseMessage: `chore: prepare release ${TODAY}`, - commitReleaseMessage: `chore: release ${TODAY}`, + commitPrepareReleaseMessage: `${commitStartPrepareRelease} ${TODAY}`, + commitReleaseMessage: `${commitStartRelease} ${TODAY}`, notification: { header: '### 🔨 The codegen job will run at the end of the CI.', body: (): string =>