This commit is contained in:
di-sukharev
2023-05-20 13:12:27 +08:00
parent 490d209c64
commit 8d09fe0b7c
3 changed files with 13 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import { execa } from 'execa';
import { intro, outro } from '@clack/prompts';
import { PullRequestEvent } from '@octokit/webhooks-types';
import { generateCommitMessageByDiff } from './generateCommitMessageFromGitDiff';
import { sleep } from './utils/sleep';
// This should be a token with access to your repository scoped in as a secret.
// The YML workflow will need to set GITHUB_TOKEN with the GitHub Secret Token
@@ -91,6 +92,9 @@ async function improveCommitMessagesWithRebase(commits: CommitsArray) {
outro(`error in Promise.all(getCommitDiffs(SHAs)): ${error}`);
throw error;
});
// openAI errors with 429 code (too many requests) so lets sleep a bit
await sleep(1000);
}
return improvedMessagesBySha;

3
src/utils/sleep.ts Normal file
View File

@@ -0,0 +1,3 @@
export function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}