INNER CODE UNIT · TypeScript

verifyApplyPatchArgs

totec448-spec/chat-on-steroids · src/main/codex/apply-patch/index.ts:579

export async function verifyApplyPatchArgs(
  args: { patch: string; hunks: readonly Hunk[]; workdir: string | null },
  cwd: string,
  updateFileMode: ApplyPatchFileUpdateMode,
  resolvePath: PatchPathResolver = defaultPathResolver
): Promise<ApplyPatchAction> {
  const effectiveCwd = args.workdir === null ? cwd : resolvePath(args.workdir, cwd);
  const changes = new Map<string, ApplyPatchFileChange>();
  const pending = new Map<string, PendingFile>();

  for (const hunk of args.hunks) {
    const path = resolveHunkPath(hunk, effectiveCwd, resolvePath);
    const before = pending.get(path);
    // The budget guards a file this call is about to read off disk. A path an earlier hunk in
    // this patch already wrote has no such read: its content is the patch's own text, which the
    // tool layer bounded before it ever reached the parser.
    if (before === undefined) await verifyPatchFileTarget(path, hunk.kind === 'add_file');

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…