Repository: atlassian/changesets
Pull request #626 (2021-08-26 15:53:27)

Ignore changeset files starting with a dot

Andarist: Something weird has happened here - I'm reopening this PR

Patch:
diff --git a/.changeset/rude-spoons-search.md b/.changeset/rude-spoons-search.md
new file mode 100644
index 0000000..8add15b
--- /dev/null
+++ b/.changeset/rude-spoons-search.md
@@ -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.
diff --git a/__fixtures__/ignored-changeset/.changeset/.ignored-temporarily.md b/__fixtures__/ignored-changeset/.changeset/.ignored-temporarily.md
new file mode 100644
index 0000000..8e84ebf
--- /dev/null
+++ b/__fixtures__/ignored-changeset/.changeset/.ignored-temporarily.md
@@ -0,0 +1,5 @@
+---
+"pkg-b": minor
+---
+
+Awesome feature, hidden behind a feature flag
diff --git a/__fixtures__/ignored-changeset/.changeset/README.md b/__fixtures__/ignored-changeset/.changeset/README.md
new file mode 100644
index 0000000..fd188f5
--- /dev/null
+++ b/__fixtures__/ignored-changeset/.changeset/README.md
@@ -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
\ No newline at end of file
diff --git a/__fixtures__/ignored-changeset/.changeset/changesets-are-beautiful.md b/__fixtures__/ignored-changeset/.changeset/changesets-are-beautiful.md
new file mode 100644
index 0000000..943b758
--- /dev/null
+++ b/__fixtures__/ignored-changeset/.changeset/changesets-are-beautiful.md
@@ -0,0 +1,5 @@
+---
+"pkg-a": minor
+---
+
+Nice simple summary, much wow
diff --git a/__fixtures__/ignored-changeset/.changeset/config.json b/__fixtures__/ignored-changeset/.changeset/config.json
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/__fixtures__/ignored-changeset/.changeset/config.json
@@ -0,0 +1,1 @@
+{}
diff --git a/__fixtures__/ignored-changeset/package.json b/__fixtures__/ignored-changeset/package.json
new file mode 100644
index 0000000..2e742d8
--- /dev/null
+++ b/__fixtures__/ignored-changeset/package.json
@@ -0,0 +1,11 @@
+{
+  "private": true,
+  "name": "simple-project",
+  "description": "three projects, each depending on one other",
+  "version": "1.0.0",
+  "bolt": {
+    "workspaces": [
+      "packages/*"
+    ]
+  }
+}
diff --git a/__fixtures__/ignored-changeset/packages/pkg-a/package.json b/__fixtures__/ignored-changeset/packages/pkg-a/package.json
new file mode 100644
index 0000000..205afc4
--- /dev/null
+++ b/__fixtures__/ignored-changeset/packages/pkg-a/package.json
@@ -0,0 +1,7 @@
+{
+  "name": "pkg-a",
+  "version": "1.0.0",
+  "dependencies": {
+    "pkg-b": "1.0.0"
+  }
+}
diff --git a/__fixtures__/ignored-changeset/packages/pkg-b/package.json b/__fixtures__/ignored-changeset/packages/pkg-b/package.json
new file mode 100644
index 0000000..be4760e
--- /dev/null
+++ b/__fixtures__/ignored-changeset/packages/pkg-b/package.json
@@ -0,0 +1,4 @@
+{
+  "name": "pkg-b",
+  "version": "1.0.0"
+}
diff --git a/packages/read/src/index.ts b/packages/read/src/index.ts
index 4bec362..aca11f9 100644
--- a/packages/read/src/index.ts
+++ b/packages/read/src/index.ts
@@ -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 => {


Test patch:
diff --git a/packages/cli/src/commands/version/version.test.ts b/packages/cli/src/commands/version/version.test.ts
index a6da75a..8d9018c 100644
--- a/packages/cli/src/commands/version/version.test.ts
+++ b/packages/cli/src/commands/version/version.test.ts
@@ -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);
diff --git a/packages/read/src/index.test.ts b/packages/read/src/index.test.ts
index bfb3cd8..c00f482 100644
--- a/packages/read/src/index.test.ts
+++ b/packages/read/src/index.test.ts
@@ -91,9 +91,9 @@ describe("read changesets from disc", () => {
       outdent`could not parse changeset - invalid frontmatter: ---
 
       "cool-package": minor
-      
+
       --
-      
+
       Everything is wrong`
     );
   });
@@ -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"
       }
     ]);
   });