Adding guard checks.
This commit is contained in:
+14
-5
@@ -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`
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user