Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the "simply-blame" extension will be documented in this file.

## [1.10.2]
### Update
- Fix open file and file path with spaces

## [1.10.1]
### Update
- Fix editor manager try open unopend editor issue
Expand Down
2 changes: 1 addition & 1 deletion src/Git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const blameFile = async (fileName: string): Promise<string> => {
const location = fileName.replace(name, '');

try {
return await command(`cd ${location} && git blame --porcelain ${name}`) ?? '';
return await command(`cd "${location}" && git blame --porcelain "${name}"`) ?? '';
} catch (e) {
if ((e as Error).message.match(/no such path .* in HEAD/)) {
vscode.window.showWarningMessage(`File: ${name} is not in HEAD`);
Expand Down
24 changes: 21 additions & 3 deletions src/test/suite/Git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,36 @@ Maybe this commit message is long and descriptive enough to prove a point.
test('test blameFile slash succeeds', async () => {
await blameFile('path/to/file/test.ts');

sinon.assert.calledWithExactly(commandStub, `cd path/to/file/ && git blame --porcelain test.ts`);
sinon.assert.calledWithExactly(commandStub, `cd \"path/to/file/\" && git blame --porcelain \"test.ts\"`);
});

test('test blameFile backslash succeeds', async () => {
await blameFile('path\\to\\file\\test.ts');

sinon.assert.calledWithExactly(commandStub, 'cd path\\to\\file\\ && git blame --porcelain test.ts');
sinon.assert.calledWithExactly(commandStub, 'cd \"path\\to\\file\\\" && git blame --porcelain \"test.ts\"');
});

test('test blameFile filename with dash succeeds', async () => {
await blameFile('path/to/file/test-this.txt');

sinon.assert.calledWithExactly(commandStub, `cd path/to/file/ && git blame --porcelain test-this.txt`);
sinon.assert.calledWithExactly(commandStub, `cd \"path/to/file/\" && git blame --porcelain \"test-this.txt\"`);
});

test('test blameFile filename with space succeeds', async () => {
await blameFile('path/to/file/test this.txt');

sinon.assert.calledWithExactly(commandStub, `cd \"path/to/file/\" && git blame --porcelain \"test this.txt\"`);
});

test('test blameFile path with space succeeds', async () => {
await blameFile('path/to my files/test.txt');

sinon.assert.calledWithExactly(commandStub, `cd \"path/to my files/\" && git blame --porcelain \"test.txt\"`);
});

test('test blameFile path and filename with space succeeds', async () => {
await blameFile('path/to my files/test this.txt');

sinon.assert.calledWithExactly(commandStub, `cd \"path/to my files/\" && git blame --porcelain \"test this.txt\"`);
});
});