MCPcopy Create free account
hub / github.com/ReviewStage/stage-cli / parseFilePathsFromPatch

Function parseFilePathsFromPatch

packages/cli/src/routes/diff.ts:128–152  ·  view source on GitHub ↗
(patch: string)

Source from the content-addressed store, hash-verified

126 }
127 },
128 },
129 ];
130}
131
132const MINUS_RE = /^--- (.+)$/m;
133const PLUS_RE = /^\+\+\+ (.+)$/m;
134const BINARY_RE = /^Binary files|^GIT binary patch/m;
135// Mode 120000 marks a symlink. Old and new sides are detected separately so a
136// symlink<->regular transition (old mode/new mode pairs) fetches each side with
137// the right reader instead of treating both as links.
138const OLD_MODE_RE = /^(?:old mode|deleted file mode) (\d{6})$/m;
139const NEW_MODE_RE = /^(?:new mode|new file mode) (\d{6})$/m;
140const INDEX_MODE_RE = /^index [0-9a-f]+\.\.[0-9a-f]+ (\d{6})$/m;
141const SYMLINK_MODE = "120000";
142const RENAME_FROM_RE = /^(?:rename|copy) from (.+)$/m;
143const RENAME_TO_RE = /^(?:rename|copy) to (.+)$/m;
144// `diff --git "a/x y" "b/x y"` — git quotes paths containing spaces or specials.
145const DIFF_GIT_QUOTED_RE = /^diff --git "a\/((?:[^"\\]|\\.)+)" "b\/((?:[^"\\]|\\.)+)"$/m;
146const DIFF_GIT_RE = /^diff --git a\/(.+) b\/(.+)$/m;
147
148interface ParsedFilePaths {
149 oldPath: string | null;
150 newPath: string | null;
151 isBinary: boolean;
152 oldIsSymlink: boolean;
153 newIsSymlink: boolean;
154 /**
155 * A pure rename/copy (100% similarity) emits only `similarity index` +

Callers 1

buildFileContentsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected