Skip to content

Commit

Permalink
Ignore changeset files starting with a dot (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Aug 29, 2021
1 parent 61ffd67 commit bc611cf
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .changeset/rude-spoons-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@changesets/read": minor
"@changesets/cli": minor
---

From now on, changeset files starting with a dot (e.g. `.ignored-temporarily.md`) will be be ignored and kept around after versioning. This allows you to prepare a changeset for something that isn't supposed to be released immediately. An example use case could involve code hidden behind a feature flag.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"pkg-b": minor
---

Awesome feature, hidden behind a feature flag
3 changes: 3 additions & 0 deletions __fixtures__/ignored-changeset/.changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# We just want a file in here so git collects it

For this we have deliberately not included a config file, as we want to test the defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"pkg-a": minor
---

Nice simple summary, much wow
1 change: 1 addition & 0 deletions __fixtures__/ignored-changeset/.changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
11 changes: 11 additions & 0 deletions __fixtures__/ignored-changeset/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"private": true,
"name": "simple-project",
"description": "three projects, each depending on one other",
"version": "1.0.0",
"bolt": {
"workspaces": [
"packages/*"
]
}
}
7 changes: 7 additions & 0 deletions __fixtures__/ignored-changeset/packages/pkg-a/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "pkg-a",
"version": "1.0.0",
"dependencies": {
"pkg-b": "1.0.0"
}
}
4 changes: 4 additions & 0 deletions __fixtures__/ignored-changeset/packages/pkg-b/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "pkg-b",
"version": "1.0.0"
}
25 changes: 25 additions & 0 deletions packages/cli/src/commands/version/version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,31 @@ describe("running version in a simple project", () => {
`);
});

it("should skip over ignored changesets", async () => {
const cwd = await f.copy("ignored-changeset");

await versionCommand(cwd, defaultOptions, modifiedDefaultConfig);

let packages = await getPackages(cwd);
expect(packages.packages.map(x => x.packageJson)).toEqual([
{
name: "pkg-a",
version: "1.1.0",
dependencies: {
"pkg-b": "1.0.0"
}
},
{
name: "pkg-b",
version: "1.0.0"
}
]);

const changesetDir = await fs.readdir(path.join(cwd, ".changeset"));
// should still contain the ignored changeset
expect(changesetDir).toContain(".ignored-temporarily.md");
});

describe("when there are multiple changeset commits", () => {
it("should bump releasedPackages", async () => {
await writeChangesets([simpleChangeset, simpleChangeset2], cwd);
Expand Down
14 changes: 7 additions & 7 deletions packages/read/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ describe("read changesets from disc", () => {
outdent`could not parse changeset - invalid frontmatter: ---
"cool-package": minor
--
Everything is wrong`
);
});
Expand All @@ -109,15 +109,15 @@ describe("read changesets from disc", () => {
}
]);
});
it("should read an old changeset", async () => {
const changesetPath = f.find("old-changeset");
it("should filter out ignored changesets", async () => {
const changesetPath = f.find("ignored-changeset");

const changesets = await read(changesetPath);
expect(changesets).toEqual([
{
releases: [{ name: "cool-package", type: "minor" }],
summary: "Nice simple summary\n",
id: "basic-changeset"
releases: [{ name: "pkg-a", type: "minor" }],
summary: "Nice simple summary, much wow",
id: "changesets-are-beautiful"
}
]);
});
Expand Down
3 changes: 2 additions & 1 deletion packages/read/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export default async function getChangesets(
let oldChangesetsPromise = getOldChangesetsAndWarn(changesetBase, contents);

let changesets = contents.filter(
file => file.endsWith(".md") && file !== "README.md"
file =>
!file.startsWith(".") && file.endsWith(".md") && file !== "README.md"
);

const changesetContents = changesets.map(async file => {
Expand Down

0 comments on commit bc611cf

Please sign in to comment.