diff --git a/out/github-action.cjs b/out/github-action.cjs index 754ebc0..8729166 100644 --- a/out/github-action.cjs +++ b/out/github-action.cjs @@ -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` ); diff --git a/src/github-action.ts b/src/github-action.ts index f2049d0..d949dd4 100644 --- a/src/github-action.ts +++ b/src/github-action.ts @@ -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( '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` );