Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 3 additions & 6 deletions get-changed-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ 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> };
bolt?: { workspaces: ReadonlyArray<string> };
Expand Down Expand Up @@ -118,12 +120,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 @@ -7,6 +7,7 @@ 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 @@ -112,12 +113,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),
)
);
}