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
8 changes: 2 additions & 6 deletions get-changed-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> | { packages: ReadonlyArray<string> };
Expand Down Expand Up @@ -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");
Expand Down
8 changes: 2 additions & 6 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
Expand Down Expand Up @@ -111,12 +112,7 @@ const hasChangesetBeenAdded = (
changedFilesPromise: ReturnType<PRContext["octokit"]["pulls"]["listFiles"]>,
) =>
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) => {
Expand Down
18 changes: 18 additions & 0 deletions is-changeset.ts
Original file line number Diff line number Diff line change
@@ -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),
)
);
}