Skip to content

Commit 1270cc6

Browse files
Merge pull request #95 from MichaelCurrin/fix-git-root-uri-not-absolute-for-windows
fix: Git root URI should not be absolute for Windows
2 parents 63bf7b4 + 2d4b362 commit 1270cc6

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Debugging
2+
> How to deal with errors in the extension
3+
4+
## Test shell commands
5+
6+
This snippet of code can be used to for testing that a basic command works without error and output can be shown.
7+
8+
```typescript
9+
/**
10+
* Debug tool for checking that a basic command works.
11+
* Replace the `makeAndFillCommitMsg` call with `test` to use this.
12+
*/
13+
async function _test(repository: Repository) {
14+
vscode.window.showInformationMessage("Testing")
15+
16+
let cwd = repository.rootUri.fsPath;
17+
18+
vscode.window.showInformationMessage(cwd)
19+
20+
const resp = await _execute(cwd, 'git --version')
21+
vscode.window.showInformationMessage(`${resp.stdout} -- ${resp.stderr}`)
22+
}
23+
```
24+
25+
### Background
26+
27+
This was prompted by issue [#93](https://github.com/MichaelCurrin/auto-commit-msg/issues/93) on Windows.
28+
29+
The output in the debug mode did not work because the shell command failed to spawn at all using `exec()` in Node.
30+
31+
The `cwd` value was incorrect from the existing logs which I didn't notice initially but using the test above made it clear.

src/git/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async function _diffIndex(
3636
repository: Repository,
3737
options: string[] = []
3838
): Promise<Array<string>> {
39-
const cwd = repository.rootUri.path;
39+
const cwd = repository.rootUri.fsPath;
4040
const cmd = "diff-index";
4141
const fullOptions = [
4242
"--name-status",

0 commit comments

Comments
 (0)