Initial open source GitHub PR review bot
This commit is contained in:
commit
c6bf0346b4
23 files changed
+4577
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import type { PullRequestFile } from "../types.js";
|
||||
|
||||
export function compactFilesForReview(files: PullRequestFile[], maxPatchChars: number): PullRequestFile[] {
|
||||
let remaining = maxPatchChars;
|
||||
|
||||
return files.map((file) => {
|
||||
if (!file.patch || remaining <= 0) {
|
||||
return { ...file, patch: undefined };
|
||||
}
|
||||
|
||||
const patch = file.patch.slice(0, remaining);
|
||||
remaining -= patch.length;
|
||||
|
||||
return {
|
||||
...file,
|
||||
patch: patch.length < file.patch.length ? `${patch}\n[patch truncated]` : patch
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user