MCPcopy Create free account
hub / github.com/agegr/pi-web / createTrackedFilePatch

Function createTrackedFilePatch

lib/git-changes.ts:101–122  ·  view source on GitHub ↗
(
  repositoryRoot: string,
  relativePath: string,
  originalPath?: string,
)

Source from the content-addressed store, hash-verified

99}
100
101async function createTrackedFilePatch(
102 repositoryRoot: string,
103 relativePath: string,
104 originalPath?: string,
105): Promise<string | null> {
106 const paths = originalPath && originalPath !== relativePath
107 ? [originalPath, relativePath]
108 : [relativePath];
109 try {
110 return await git(repositoryRoot, [
111 "diff",
112 "--no-color",
113 "--no-ext-diff",
114 "--unified=3",
115 "HEAD",
116 "--",
117 ...paths,
118 ], TEXT_PREVIEW_MAX_BYTES * 4);
119 } catch {
120 return null;
121 }
122}
123
124export async function getGitFileDiff(cwd: string, filePath: string): Promise<GitFileDiffResponse> {
125 const repositoryRoot = await findRepositoryRoot(cwd);

Callers 1

getGitFileDiffFunction · 0.85

Calls 1

gitFunction · 0.70

Tested by

no test coverage detected