Repository: atlassian/changesets (ts)

Issue:
@changesets/git: getChangedPackagesSinceRef always returns values
## Affected Packages

`@changesets/git`

## Problem

Untested with a monorepo, but calling `getChangedPackagesSinceRef` against a single package with no changes, results in the package being returned.

This is because `getChangedFilesSince(... fullPath: false)` will return `[""]`, rather than the expected `[]`.
`getChangedFilesSince(... fullPath: true)` will join that empty string with the path, and imply that the package has changed.

## Proposed solution

Filter empty strings from `getChangedFilesSince`

Pull request description:
dont return paths for unchanged packages
Fixes #416 

Patch:
diff --git a/.changeset/curvy-ducks-end.md b/.changeset/curvy-ducks-end.md
new file mode 100644
index 0000000..75685fc
--- /dev/null
+++ b/.changeset/curvy-ducks-end.md
@@ -0,0 +1,5 @@
+---
+"@changesets/git": patch
+---
+
+Don't return paths for unchanged packages
diff --git a/packages/git/src/index.ts b/packages/git/src/index.ts
index 70bcb2b..0091ce2 100644
--- a/packages/git/src/index.ts
+++ b/packages/git/src/index.ts
@@ -73,7 +73,8 @@ async function getChangedFilesSince({
   const files = cmd.stdout
     .toString()
     .trim()
-    .split("\n");
+    .split("\n")
+    .filter(a => a);
   if (!fullPath) return files;
   return files.map(file => path.resolve(cwd, file));
 }


Test patch:
diff --git a/packages/git/src/index.test.ts b/packages/git/src/index.test.ts
index 25752de..dfb7652 100644
--- a/packages/git/src/index.test.ts
+++ b/packages/git/src/index.test.ts
@@ -208,13 +208,24 @@ describe("git", () => {
       await commit("added packageA package.json", cwd);
     });
 
-    it("should be empty if no changes", async () => {
+    it("should be empty if no changes (partial path)", async () => {
       const head = await spawn("git", ["rev-parse", "HEAD"], { cwd });
       const changedFiles = await getChangedFilesSince({
         ref: head.stdout.toString().trim(),
-        cwd
+        cwd,
+        fullPath: false
+      });
+      expect(changedFiles).toHaveLength(0);
+    });
+
+    it("should be empty if no changes (full path)", async () => {
+      const head = await spawn("git", ["rev-parse", "HEAD"], { cwd });
+      const changedFiles = await getChangedFilesSince({
+        ref: head.stdout.toString().trim(),
+        cwd,
+        fullPath: true
       });
-      expect(changedFiles.filter(a => a)).toHaveLength(0);
+      expect(changedFiles).toHaveLength(0);
     });
 
     it("should get list of files that have been committed", async () => {