mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-04-20 03:02:51 -04:00
build
This commit is contained in:
@@ -71,20 +71,27 @@ async function improveCommitMessagesWithRebase(commits: CommitsArray) {
|
||||
generateCommitMessageByDiff(commit.diff)
|
||||
);
|
||||
|
||||
console.log({ commitDiffs });
|
||||
let improvedMessagesBySha: MessageBySha = {};
|
||||
// send batches of 3 diffs in parallel, because openAI restricts too many requests at once with 429 error
|
||||
const step = 3;
|
||||
for (let i = 0; i < improvePromises.length; i + step) {
|
||||
const promises = improvePromises.slice(i, step);
|
||||
await Promise.all(promises)
|
||||
.then((results) => {
|
||||
return results.reduce((acc, improvedMsg, i) => {
|
||||
acc[commitDiffs[i].sha] = improvedMsg;
|
||||
|
||||
return acc;
|
||||
}, improvedMessagesBySha);
|
||||
})
|
||||
.catch((error) => {
|
||||
outro(`error in Promise.all(getCommitDiffs(SHAs)): ${error}`);
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
console.log({ improvedMessagesBySha });
|
||||
|
||||
const improvedMessagesBySha: MessageBySha = await Promise.all(improvePromises)
|
||||
.then((results) => {
|
||||
return results.reduce((acc, improvedMsg, i) => {
|
||||
console.log({ i, sha: commitDiffs[i].sha, improvedMsg });
|
||||
acc[commitDiffs[i].sha] = improvedMsg;
|
||||
return acc;
|
||||
}, {} as MessageBySha);
|
||||
})
|
||||
.catch((error) => {
|
||||
outro(`error in Promise.all(getCommitDiffs(SHAs)): ${error}`);
|
||||
throw error;
|
||||
});
|
||||
outro('Done.');
|
||||
|
||||
outro(
|
||||
|
||||
Reference in New Issue
Block a user