Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions get-changed-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const getChangedPackages = async ({
if (!item.path) {
continue;
}
if (item.path.endsWith("/package.json")) {
if (nodePath.basename(item.path) === "package.json") {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to understand better your workspace layout to determine if this is the proper fix. How your packages are laid out and how your workspaces patterns are configured? what exactly doesnt work right now and what is the expected result with your fix in?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I described one example in more detail as part of #82

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukasIO so basically what I put now in a test case 58f9485 ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that looks right, there's one more case that this didn't fix, I opened #111 to address it

const dirPath = nodePath.dirname(item.path);
potentialWorkspaceDirectories.push(dirPath);
} else if (item.path === "pnpm-workspace.yaml") {
Expand All @@ -132,7 +132,10 @@ export const getChangedPackages = async ({
const id = res[1];

changesetPromises.push(
fetchTextFile(item.path).then((text) => ({ ...parseChangeset(text), id })),
fetchTextFile(item.path).then((text) => ({
...parseChangeset(text),
id,
})),
);
}
}
Expand Down
69 changes: 69 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,75 @@ describe.concurrent("changeset-bot", () => {
`);
});

it("shows release details for the root package when workspaces explicitly include dot", async ({
expect,
task,
}) => {
const probot = setupProbot(task.id);
const { requests } = usePrState(server, {
files: {
".changeset/config.json": JSON.stringify({}),
".changeset/root-change.md": [
{
status: "added",
},
`---
"root-package": patch
---

thing
`,
],
"package.json": JSON.stringify({
name: "root-package",
version: "1.0.0",
workspaces: [".", "packages/*"],
}),
"packages/a/package.json": JSON.stringify({
name: "pkg-a",
}),
},
comments: [],
});

await probot.receive({
name: "pull_request",
payload: pullRequestOpen,
} as never);

const commentRequests = requests.filter((request) => request.path.includes("/comments"));

expect(commentRequests).toMatchInlineSnapshot(`
[
{
"body": {
"body": "### 🦋 Changeset detected

Latest commit: c4d7edfd758bd44f7d4264fb55f6033f56d79540

**The changes in this PR will be included in the next version bump.**

<details><summary>This PR includes changesets to release 1 package</summary>

| Name | Type |
| ------------ | ----- |
| root-package | Patch |

</details>

Not sure what this means? [Click here to learn what changesets are](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add another changeset to this PR](https://github.com/changesets/bot/new/test?filename=.changeset/<CHANGESET_FILE>.md&value=---%0A%0A---%0A%0Athing%0A)

",
},
"method": "POST",
"path": "/repos/changesets/bot/issues/2/comments",
},
]
`);
});

it("includes only changed yarn workspace packages in the add-changeset link", async ({
expect,
task,
Expand Down