Skip to content

Commit 11f8231

Browse files
authored
Ignore agent files as changesets (#120)
* Ignore agent files as changesets ref: changesets/changesets#2066 * Fix lint and test
1 parent d5456a7 commit 11f8231

3 files changed

Lines changed: 23 additions & 12 deletions

File tree

get-changed-packages.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import jsYaml from "js-yaml";
1313
import micromatch from "micromatch";
1414
import type { ProbotOctokit } from "probot";
1515

16+
import { isChangeset } from "./is-changeset.ts";
17+
1618
interface PackageJSON extends ChangesetPackageJSON {
1719
workspaces?: ReadonlyArray<string> | { packages: ReadonlyArray<string> };
1820
bolt?: { workspaces: ReadonlyArray<string> };
@@ -117,12 +119,7 @@ export const getChangedPackages = async ({
117119
isPnpm = true;
118120
} else if (item.path === ".changeset/pre.json") {
119121
preStatePromise = fetchJsonFile(".changeset/pre.json");
120-
} else if (
121-
item.path !== ".changeset/README.md" &&
122-
item.path.startsWith(".changeset") &&
123-
item.path.endsWith(".md") &&
124-
changedFiles.includes(item.path)
125-
) {
122+
} else if (changedFiles.includes(item.path) && isChangeset(item.path)) {
126123
const res = /\.changeset\/([^.]+)\.md/.exec(item.path);
127124
if (!res) {
128125
throw new Error("could not get name from changeset filename");

index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { humanId } from "human-id";
66
import markdownTable from "markdown-table";
77
import type { Probot, Context } from "probot";
88
import { getChangedPackages } from "./get-changed-packages.ts";
9+
import { isChangeset } from "./is-changeset.ts";
910

1011
const getReleasePlanMessage = (releasePlan: ReleasePlan | null) => {
1112
if (!releasePlan) return "";
@@ -111,12 +112,7 @@ const hasChangesetBeenAdded = (
111112
changedFilesPromise: ReturnType<PRContext["octokit"]["pulls"]["listFiles"]>,
112113
) =>
113114
changedFilesPromise.then((filesResponse) =>
114-
filesResponse.data.some(
115-
(file) =>
116-
file.status === "added" &&
117-
/^\.changeset\/.+\.md$/.test(file.filename) &&
118-
file.filename !== ".changeset/README.md",
119-
),
115+
filesResponse.data.some((file) => file.status === "added" && isChangeset(file.filename)),
120116
);
121117

122118
export default (app: Probot) => {

is-changeset.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Files in `.changeset` that should not be considered as changesets.
2+
// Should match `@changesets/read`.
3+
const ignoredMdFiles = [/^README\.md$/i, "AGENTS.md", "CLAUDE.md", "GEMINI.md"];
4+
5+
export function isChangeset(filename: string) {
6+
if (!filename.startsWith(".changeset/")) return false;
7+
8+
const file = filename.slice(".changeset/".length);
9+
10+
// Perform same check as `@changesets/read`
11+
return (
12+
!file.startsWith(".") &&
13+
file.endsWith(".md") &&
14+
!ignoredMdFiles.some((pattern) =>
15+
typeof pattern === "string" ? pattern === file : pattern.test(file),
16+
)
17+
);
18+
}

0 commit comments

Comments
 (0)