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

Function getChangedPackagesSinceRef

packages/git/src/index.ts:253–287  ·  view source on GitHub ↗
({
  cwd,
  ref,
  changedFilePatterns = ["**"],
}: {
  cwd: string;
  ref: string;
  changedFilePatterns?: readonly string[];
})

Source from the content-addressed store, hash-verified

251}
252
253export async function getChangedPackagesSinceRef({
254 cwd,
255 ref,
256 changedFilePatterns = ["**"],
257}: {
258 cwd: string;
259 ref: string;
260 changedFilePatterns?: readonly string[];
261}): Promise<Package[]> {
262 const changedFiles = await getChangedFilesSince({ ref, cwd, fullPath: true });
263
264 return (
265 [...(await getPackages(cwd)).packages]
266 // sort packages by length of dir, so that we can check for subdirs first
267 .sort((pkgA, pkgB) => pkgB.dir.length - pkgA.dir.length)
268 .filter((pkg) => {
269 const changedPackageFiles: string[] = [];
270
271 for (let i = changedFiles.length - 1; i >= 0; i--) {
272 const file = changedFiles[i];
273
274 if (isSubdir(pkg.dir, file)) {
275 changedFiles.splice(i, 1);
276 const relativeFile = file.slice(pkg.dir.length + 1);
277 changedPackageFiles.push(relativeFile);
278 }
279 }
280
281 return (
282 changedPackageFiles.length > 0 &&
283 micromatch(changedPackageFiles, changedFilePatterns).length > 0
284 );
285 })
286 );
287}
288
289export async function tagExists(tagStr: string, cwd: string) {
290 const gitCmd = await spawn("git", ["tag", "-l", tagStr], { cwd });

Callers 2

index.test.tsFile · 0.85

Calls 1

getChangedFilesSinceFunction · 0.85

Tested by

no test coverage detected