Skip to content

Commit d89b1ce

Browse files
authored
fix(script): prevent throw on gen code change (#425)
1 parent 32416dc commit d89b1ce

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

scripts/ci/codegen/pushGeneratedCode.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import text from './text';
88
const PR_NUMBER = parseInt(process.env.PR_NUMBER || '0', 10);
99
const FOLDERS_TO_CHECK = 'yarn.lock openapitools.json clients specs/bundled';
1010

11-
async function isUpToDate(): Promise<boolean> {
11+
async function isUpToDate(baseBranch: string): Promise<boolean> {
1212
await run('git fetch origin');
13-
return (await run('git status')).includes('Your branch is up to date with');
13+
return (await run(`git pull origin ${baseBranch}`)).includes(
14+
'Already up to date.'
15+
);
1416
}
1517

1618
/**
@@ -55,9 +57,9 @@ export async function pushGeneratedCode(): Promise<void> {
5557
await run(`git checkout -b ${branchToPush}`);
5658
}
5759

58-
if (!(await isUpToDate())) {
60+
if (!(await isUpToDate(baseBranch))) {
5961
console.log(
60-
`The branch ${branchToPush} is not up to date with ${baseBranch}, stopping this task and letting the new job push generated code.`
62+
`The branch '${baseBranch}' is not up to date with origin, stopping this task and letting the new job push generated code.`
6163
);
6264
return;
6365
}

0 commit comments

Comments
 (0)