Adding guard checks.
Testing / prettier (push) Failing after 2m4s
Testing / e2e-test (20.x) (push) Failing after 2m27s
Testing / unit-test (20.x) (push) Failing after 3m28s
CodeQL / Analyze (javascript) (push) Failing after 41s

This commit is contained in:
2026-01-04 15:24:12 -05:00
parent 7fefe34240
commit ba33f9c4a3
2 changed files with 33 additions and 10 deletions
+14 -5
View File
@@ -93626,11 +93626,11 @@ async function getCommitDiff(commitSha) {
);
const diff2 = response.data ?? "";
if (!diff2) {
core.warning(`No diff data for commit ${commitSha}`);
core.warning(`\u26A0\uFE0F No diff returned for commit ${commitSha}`);
}
return { sha: commitSha, diff: diff2 };
} catch (error2) {
core.error(`Error fetching Gitea/Forgejo diff for ${commitSha}: ${error2}`);
core.error(`Failed to fetch Gitea/Forgejo commit diff for ${commitSha}: ${error2}`);
throw error2;
}
}
@@ -93640,12 +93640,14 @@ async function getCommitDiff(commitSha) {
owner,
repo,
ref: commitSha,
headers: { Accept: "application/vnd.github.v3.diff" }
headers: {
Accept: "application/vnd.github.v3.diff"
}
}
);
const diff = diffResponse.data ?? "";
if (!diff) {
core.warning(`No diff data from GitHub for commit ${commitSha}`);
core.warning(`\u26A0\uFE0F No diff returned from GitHub for commit ${commitSha}`);
}
return { sha: commitSha, diff };
}
@@ -93715,7 +93717,14 @@ async function improveCommitMessages(commitsToImprove) {
const commitSHAsToImprove = filteredCommits.map((commit) => commit.id);
const diffsWithSHAs = await getDiffsBySHAs(commitSHAsToImprove);
ce("Done.");
const improvedMessagesWithSHAs = await improveMessagesInChunks(diffsWithSHAs);
const validDiffsWithSHAs = diffsWithSHAs.filter(
(item) => typeof item.diff === "string" && item.diff.length > 0
);
if (validDiffsWithSHAs.length === 0) {
ce("No valid diffs received; skipping improvement step.");
return;
}
const improvedMessagesWithSHAs = await improveMessagesInChunks(validDiffsWithSHAs);
console.log(
`Improved ${improvedMessagesWithSHAs.length} commit messages`
);
+19 -5
View File
@@ -50,29 +50,32 @@ async function getCommitDiff(commitSha: string): Promise<{ sha: SHA; diff: Diff
const diff = response.data ?? '';
if (!diff) {
core.warning(`No diff data for commit ${commitSha}`);
core.warning(`⚠️ No diff returned for commit ${commitSha}`);
}
return { sha: commitSha, diff };
} catch (error) {
core.error(`Error fetching Gitea/Forgejo diff for ${commitSha}: ${error}`);
core.error(`Failed to fetch Gitea/Forgejo commit diff for ${commitSha}: ${error}`);
throw error;
}
}
// GitHub path unchanged
const diffResponse = await octokit.request<string>(
'GET /repos/{owner}/{repo}/commits/{ref}',
{
owner,
repo,
ref: commitSha,
headers: { Accept: 'application/vnd.github.v3.diff' },
headers: {
Accept: 'application/vnd.github.v3.diff',
},
}
);
const diff = diffResponse.data ?? '';
if (!diff) {
core.warning(`No diff data from GitHub for commit ${commitSha}`);
core.warning(`⚠️ No diff returned from GitHub for commit ${commitSha}`);
}
return { sha: commitSha, diff };
@@ -175,7 +178,18 @@ async function improveCommitMessages(
const diffsWithSHAs = await getDiffsBySHAs(commitSHAsToImprove);
outro('Done.');
const improvedMessagesWithSHAs = await improveMessagesInChunks(diffsWithSHAs);
// 🛡️ FILTER OUT EMPTY Diffs
const validDiffsWithSHAs = diffsWithSHAs.filter(
(item) => typeof item.diff === 'string' && item.diff.length > 0
);
if (validDiffsWithSHAs.length === 0) {
outro('No valid diffs received; skipping improvement step.');
return;
}
// Proceed with non-null diffs
const improvedMessagesWithSHAs = await improveMessagesInChunks(validDiffsWithSHAs);
console.log(
`Improved ${improvedMessagesWithSHAs.length} commit messages`
);