Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an infinite loop with fixed & ignored package depending on another release #769

Merged
merged 1 commit into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/funny-cooks-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@changesets/assemble-release-plan": patch
"@changesets/cli": patch
---

Fixed an infinite loop involving a fixed group of packages and a package within that group that was both ignored and dependent on another package from that group.
2 changes: 1 addition & 1 deletion packages/assemble-release-plan/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function assembleReleasePlan(
let fixedConstraintUpdated = matchFixedConstraint(
releases,
packagesByName,
config.fixed
config
);
let linksUpdated = applyLinks(releases, packagesByName, config.linked);

Expand Down
9 changes: 6 additions & 3 deletions packages/assemble-release-plan/src/match-fixed-constraint.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Fixed } from "@changesets/types";
import { Config } from "@changesets/types";
import { Package } from "@manypkg/get-packages";
import { InternalRelease } from "./types";
import { getCurrentHighestVersion, getHighestReleaseType } from "./utils";

export default function matchFixedConstraint(
releases: Map<string, InternalRelease>,
packagesByName: Map<string, Package>,
fixed: Fixed
config: Config
): boolean {
let updated = false;

for (let fixedPackages of fixed) {
for (let fixedPackages of config.fixed) {
let releasingFixedPackages = [...releases.values()].filter(
release => fixedPackages.includes(release.name) && release.type !== "none"
);
Expand All @@ -25,6 +25,9 @@ export default function matchFixedConstraint(

// Finally, we update the packages so all of them are on the highest version
for (let pkgName of fixedPackages) {
if (config.ignore.includes(pkgName)) {
continue;
}
let release = releases.get(pkgName);

if (!release) {
Expand Down
28 changes: 28 additions & 0 deletions packages/cli/src/commands/version/version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,34 @@ describe("fixed", () => {
);
});

it("should not bump an ignored fixed package that depends on a package from the group that is being released", async () => {
const cwd = await f.copy("fixed-packages");
await writeChangesets([simpleChangeset3], cwd);

await version(cwd, defaultOptions, {
...modifiedDefaultConfig,
fixed: [["pkg-a", "pkg-b"]],
ignore: ["pkg-a"]
});

expect((await getPackages(cwd)).packages.map(x => x.packageJson))
.toMatchInlineSnapshot(`
Array [
Object {
"dependencies": Object {
"pkg-b": "1.0.1",
},
"name": "pkg-a",
"version": "1.0.0",
},
Object {
"name": "pkg-b",
"version": "1.0.1",
},
]
`);
});

it("should update CHANGELOGs of all packages from the fixed group", async () => {
const cwd = await f.copy("fixed-packages");
const spy = jest.spyOn(fs, "writeFile");
Expand Down