diff --git a/get-changed-packages.ts b/get-changed-packages.ts index 1acba91..dff58c2 100644 --- a/get-changed-packages.ts +++ b/get-changed-packages.ts @@ -12,6 +12,7 @@ import type { Packages, Tool } from "@manypkg/get-packages"; import jsYaml from "js-yaml"; import micromatch from "micromatch"; import type { ProbotOctokit } from "probot"; +import { isChangeset } from "./is-changeset.ts"; interface PackageJSON extends ChangesetPackageJSON { workspaces?: ReadonlyArray | { packages: ReadonlyArray }; @@ -117,12 +118,7 @@ export const getChangedPackages = async ({ isPnpm = true; } else if (item.path === ".changeset/pre.json") { preStatePromise = fetchJsonFile(".changeset/pre.json"); - } else if ( - item.path !== ".changeset/README.md" && - item.path.startsWith(".changeset") && - item.path.endsWith(".md") && - changedFiles.includes(item.path) - ) { + } else if (changedFiles.includes(item.path) && isChangeset(item.path)) { const res = /\.changeset\/([^.]+)\.md/.exec(item.path); if (!res) { throw new Error("could not get name from changeset filename"); diff --git a/index.ts b/index.ts index 1651a3a..b5acba1 100644 --- a/index.ts +++ b/index.ts @@ -6,6 +6,7 @@ import { humanId } from "human-id"; import markdownTable from "markdown-table"; import type { Probot, Context } from "probot"; import { getChangedPackages } from "./get-changed-packages.ts"; +import { isChangeset } from "./is-changeset.ts"; const getReleasePlanMessage = (releasePlan: ReleasePlan | null) => { if (!releasePlan) return ""; @@ -111,12 +112,7 @@ const hasChangesetBeenAdded = ( changedFilesPromise: ReturnType, ) => changedFilesPromise.then((filesResponse) => - filesResponse.data.some( - (file) => - file.status === "added" && - /^\.changeset\/.+\.md$/.test(file.filename) && - file.filename !== ".changeset/README.md", - ), + filesResponse.data.some((file) => file.status === "added" && isChangeset(file.filename)), ); export default (app: Probot) => { diff --git a/is-changeset.ts b/is-changeset.ts new file mode 100644 index 0000000..b96f7ab --- /dev/null +++ b/is-changeset.ts @@ -0,0 +1,18 @@ +// Files in `.changeset` that should not be considered as changesets. +// Should match `@changesets/read`. +const ignoredMdFiles = [/^README\.md$/i, "AGENTS.md", "CLAUDE.md", "GEMINI.md"]; + +export function isChangeset(filename: string) { + if (!filename.startsWith(".changeset/")) return false; + + const file = filename.slice(".changeset/".length); + + // Perform same check as `@changesets/read` + return ( + !file.startsWith(".") && + file.endsWith(".md") && + !ignoredMdFiles.some((pattern) => + typeof pattern === "string" ? pattern === file : pattern.test(file), + ) + ); +}