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

Function getRelevantChangesets

packages/assemble-release-plan/src/index.ts:273–322  ·  view source on GitHub ↗
(
  changesets: NewChangeset[],
  packagesByName: Map<string, Package>,
  config: Config,
  preState: PreState | undefined
)

Source from the content-addressed store, hash-verified

271}
272
273function getRelevantChangesets(
274 changesets: NewChangeset[],
275 packagesByName: Map<string, Package>,
276 config: Config,
277 preState: PreState | undefined
278): NewChangeset[] {
279 for (const changeset of changesets) {
280 // Using the following 2 arrays to decide whether a changeset
281 // contains both skipped and not skipped packages
282 const skippedPackages = [];
283 const notSkippedPackages = [];
284 for (const release of changeset.releases) {
285 // this acts as an early validation in this package so we don't throw an internal error here
286 const packageByName = mapGetOrThrow(
287 packagesByName,
288 release.name,
289 `Found changeset ${changeset.id} for package ${release.name} which is not in the workspace`
290 );
291
292 if (
293 shouldSkipPackage(packageByName, {
294 ignore: config.ignore,
295 allowPrivatePackages: config.privatePackages.version,
296 })
297 ) {
298 skippedPackages.push(release.name);
299 } else {
300 notSkippedPackages.push(release.name);
301 }
302 }
303
304 if (skippedPackages.length > 0 && notSkippedPackages.length > 0) {
305 throw new Error(
306 `Found mixed changeset ${changeset.id}\n` +
307 `Found ignored packages: ${skippedPackages.join(" ")}\n` +
308 `Found not ignored packages: ${notSkippedPackages.join(" ")}\n` +
309 "Mixed changesets that contain both ignored and not ignored packages are not allowed"
310 );
311 }
312 }
313
314 if (preState && preState.mode !== "exit") {
315 let usedChangesetIds = new Set(preState.changesets);
316 return changesets.filter(
317 (changeset) => !usedChangesetIds.has(changeset.id)
318 );
319 }
320
321 return changesets;
322}
323
324function getHighestPreVersion(
325 groupKind: "linked" | "fixed",

Callers 1

assembleReleasePlanFunction · 0.85

Calls 2

mapGetOrThrowFunction · 0.90
shouldSkipPackageFunction · 0.90

Tested by

no test coverage detected