Skip to content

Commit

Permalink
fix: keep splitter if no path specs exist (#929)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaszub committed Jun 21, 2023
1 parent f101061 commit 2ab1936
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/nice-laws-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'simple-git': patch
---

keep path splitter without path specs
5 changes: 4 additions & 1 deletion simple-git/src/lib/plugins/suffix-paths.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ export function suffixPathsPlugin(): SimpleGitPlugin<'spawn.args'> {
action(data) {
const prefix: string[] = [];
const suffix: string[] = [];
let suffixFound: boolean = false;

for (let i = 0; i < data.length; i++) {
const param = data[i];

if (isPathSpec(param)) {
suffixFound = true;
suffix.push(...toPaths(param));
continue;
}

if (param === '--') {
suffixFound = true;
suffix.push(
...data
.slice(i + 1)
Expand All @@ -28,7 +31,7 @@ export function suffixPathsPlugin(): SimpleGitPlugin<'spawn.args'> {
prefix.push(param);
}

return !suffix.length ? prefix : [...prefix, '--', ...suffix.map(String)];
return suffixFound ? [...prefix, '--', ...suffix.map(String)] : prefix;
},
};
}
8 changes: 8 additions & 0 deletions simple-git/test/unit/plugin.pathspec.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,12 @@ describe('suffixPathsPlugin', function () {
await closeWithSuccess();
assertExecutedCommands('pull', 'foo', 'bar', '--', 'a', 'b', 'c', 'd');
});

it('keep splitter without path specs', async () => {
git.raw(['a', '--']);
await closeWithSuccess();

assertExecutedCommands('a', '--');
});

});

0 comments on commit 2ab1936

Please sign in to comment.