This commit is contained in:
di-sukharev
2023-05-20 16:57:56 +08:00
parent cbd2138552
commit fd5bccbcb1
2 changed files with 19 additions and 11 deletions

View File

@@ -27937,7 +27937,7 @@ async function improveCommitMessagesWithRebase(commits, diffs) {
ce("Done.");
}
async function improveMessagesInChunks() {
const chunkSize = 1;
const chunkSize = diffs.length % 2 === 0 ? 4 : 3;
ce(`Improving commit messages with GPT in chunks of ${chunkSize}.`);
const improvePromises = diffs.map(
(commit) => generateCommitMessageByDiff(commit.diff)
@@ -28003,13 +28003,17 @@ async function run(retries = 3) {
if (import_github.default.context.eventName === "pull_request") {
const baseBranch = import_github.default.context.payload.pull_request?.base.ref;
const sourceBranch = import_github.default.context.payload.pull_request?.head.ref;
ce("Pull Request opened");
ce(
`Pull Request from source: (${sourceBranch}) to base: (${baseBranch})`
);
if (import_github.default.context.payload.action === "opened")
ce(`Pull Request opened from ${sourceBranch} to ${baseBranch}`);
ce("Pull Request action: opened");
else if (import_github.default.context.payload.action === "synchronize")
ce("New commits are pushed");
ce("Pull Request action: synchronize");
else
return ce("Unhandled action: " + import_github.default.context.payload.action);
return ce(
"Pull Request unhandled action: " + import_github.default.context.payload.action
);
const payload = import_github.default.context.payload;
const commitsResponse = await octokit.rest.pulls.listCommits({
owner,

View File

@@ -73,7 +73,7 @@ async function improveCommitMessagesWithRebase(
// send chunks of diffs in parallel, because openAI restricts too many requests at once with 429 error
async function improveMessagesInChunks() {
const chunkSize = 1;
const chunkSize = diffs!.length % 2 === 0 ? 4 : 3;
outro(`Improving commit messages with GPT in chunks of ${chunkSize}.`);
const improvePromises = diffs!.map((commit) =>
generateCommitMessageByDiff(commit.diff)
@@ -166,13 +166,17 @@ async function run(retries = 3) {
if (github.context.eventName === 'pull_request') {
const baseBranch = github.context.payload.pull_request?.base.ref;
const sourceBranch = github.context.payload.pull_request?.head.ref;
outro('Pull Request opened');
outro(
`Pull Request from source: (${sourceBranch}) to base: (${baseBranch})`
);
if (github.context.payload.action === 'opened')
outro(`Pull Request opened from ${sourceBranch} to ${baseBranch}`);
outro('Pull Request action: opened');
else if (github.context.payload.action === 'synchronize')
outro('New commits are pushed');
else return outro('Unhandled action: ' + github.context.payload.action);
outro('Pull Request action: synchronize');
else
return outro(
'Pull Request unhandled action: ' + github.context.payload.action
);
const payload = github.context.payload as PullRequestEvent;