diff --git a/src/github/data/fetcher.ts b/src/github/data/fetcher.ts index 8d0e6ebbe..620fdc78e 100644 --- a/src/github/data/fetcher.ts +++ b/src/github/data/fetcher.ts @@ -341,13 +341,21 @@ export async function fetchGitHubData({ let changedFilesWithSHA: GitHubFileWithSHA[] = []; if (isPR && changedFiles.length > 0) { changedFilesWithSHA = changedFiles.map((file) => { - // Don't compute SHA for deleted files + // Don't compute SHA for deleted or added files - deleted files no longer + // exist, and added files may not exist yet if the PR branch hasn't been + // checked out (fetchGitHubData runs before setupBranch). if (file.changeType === "DELETED") { return { ...file, sha: "deleted", }; } + if (file.changeType === "ADDED") { + return { + ...file, + sha: "added", + }; + } try { // Use git hash-object to compute the SHA for the current file content