MCPcopy Index your code
hub / github.com/changesets/changesets / getChangedFilesSince

Function getChangedFilesSince

packages/git/src/index.ts:187–218  ·  view source on GitHub ↗
({
  cwd,
  ref,
  fullPath = false,
}: {
  cwd: string;
  ref: string;
  fullPath?: boolean;
})

Source from the content-addressed store, hash-verified

185}
186
187export async function getChangedFilesSince({
188 cwd,
189 ref,
190 fullPath = false,
191}: {
192 cwd: string;
193 ref: string;
194 fullPath?: boolean;
195}): Promise<Array<string>> {
196 const divergedAt = await getDivergedCommit(cwd, ref);
197 // Now we can find which files we added
198 const cmd = await spawn(
199 "git",
200 ["diff", "--name-only", "--no-relative", divergedAt],
201 { cwd }
202 );
203 if (cmd.code !== 0) {
204 throw new Error(
205 `Failed to diff against ${divergedAt}. Is ${divergedAt} a valid ref?`
206 );
207 }
208
209 const files = cmd.stdout
210 .toString()
211 .trim()
212 .split("\n")
213 .filter((a) => a);
214 if (!fullPath) return files;
215
216 const repoRoot = await getRepoRoot({ cwd });
217 return files.map((file) => path.resolve(repoRoot, file));
218}
219
220// below are less generic functions that we use in combination with other things we are doing
221export async function getChangedChangesetFilesSinceRef({

Callers 2

index.test.tsFile · 0.85

Calls 2

getDivergedCommitFunction · 0.85
getRepoRootFunction · 0.85

Tested by

no test coverage detected