mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-01-12 23:28:16 -05:00
build
This commit is contained in:
@@ -27935,21 +27935,25 @@ async function improveCommitMessagesWithRebase(commits) {
|
||||
const improvePromises = commitDiffs.map(
|
||||
(commit) => generateCommitMessageByDiff(commit.diff)
|
||||
);
|
||||
let improvedMessagesBySha = {};
|
||||
const chunkSize = improvePromises.length % 2 === 0 ? 2 : 3;
|
||||
for (let i2 = 0; i2 < improvePromises.length; i2 += chunkSize) {
|
||||
console.log({ i: i2, improvedMessagesBySha });
|
||||
const promises = improvePromises.slice(i2, i2 + chunkSize);
|
||||
await Promise.all(promises).then((results) => {
|
||||
return results.reduce((acc, improvedMsg, i3) => {
|
||||
acc[commitDiffs[i3].sha] = improvedMsg;
|
||||
return acc;
|
||||
}, improvedMessagesBySha);
|
||||
}).catch((error) => {
|
||||
ce(`error in Promise.all(getCommitDiffs(SHAs)): ${error}`);
|
||||
throw error;
|
||||
});
|
||||
async function improveMessagesInChunks() {
|
||||
const chunkSize = improvePromises.length % 2 === 0 ? 2 : 3;
|
||||
let improvedMessagesBySha2 = {};
|
||||
for (let i2 = 0; i2 < improvePromises.length; i2 += chunkSize) {
|
||||
console.log({ i: i2, improvedMessagesBySha: improvedMessagesBySha2 });
|
||||
const promises = improvePromises.slice(i2, i2 + chunkSize);
|
||||
await Promise.all(promises).then((results) => {
|
||||
return results.reduce((acc, improvedMsg, i3) => {
|
||||
acc[commitDiffs[i3].sha] = improvedMsg;
|
||||
return acc;
|
||||
}, improvedMessagesBySha2);
|
||||
}).catch((error) => {
|
||||
ce(`error in Promise.all(getCommitDiffs(SHAs)): ${error}`);
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
return improvedMessagesBySha2;
|
||||
}
|
||||
const improvedMessagesBySha = await improveMessagesInChunks();
|
||||
console.log({ improvedMessagesBySha });
|
||||
ce("Done.");
|
||||
ce(
|
||||
|
||||
@@ -71,26 +71,32 @@ async function improveCommitMessagesWithRebase(commits: CommitsArray) {
|
||||
generateCommitMessageByDiff(commit.diff)
|
||||
);
|
||||
|
||||
let improvedMessagesBySha: MessageBySha = {};
|
||||
// send chunks of 3 diffs in parallel, because openAI restricts too many requests at once with 429 error
|
||||
const chunkSize = improvePromises.length % 2 === 0 ? 2 : 3;
|
||||
for (let i = 0; i < improvePromises.length; i += chunkSize) {
|
||||
console.log({ i, improvedMessagesBySha });
|
||||
const promises = improvePromises.slice(i, i + chunkSize);
|
||||
await Promise.all(promises)
|
||||
.then((results) => {
|
||||
return results.reduce((acc, improvedMsg, i) => {
|
||||
acc[commitDiffs[i].sha] = improvedMsg;
|
||||
async function improveMessagesInChunks() {
|
||||
const chunkSize = improvePromises.length % 2 === 0 ? 2 : 3;
|
||||
let improvedMessagesBySha: MessageBySha = {};
|
||||
for (let i = 0; i < improvePromises.length; i += chunkSize) {
|
||||
console.log({ i, improvedMessagesBySha });
|
||||
const promises = improvePromises.slice(i, i + chunkSize);
|
||||
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;
|
||||
});
|
||||
return acc;
|
||||
}, improvedMessagesBySha);
|
||||
})
|
||||
.catch((error) => {
|
||||
outro(`error in Promise.all(getCommitDiffs(SHAs)): ${error}`);
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
return improvedMessagesBySha;
|
||||
}
|
||||
|
||||
const improvedMessagesBySha = await improveMessagesInChunks();
|
||||
|
||||
console.log({ improvedMessagesBySha });
|
||||
|
||||
outro('Done.');
|
||||
|
||||
Reference in New Issue
Block a user