Skip to content

Commit 994f3b0

Browse files
authoredAug 21, 2020
fix(cli): determine correct location of COMMIT_EDITMSG (#737)
If using git working trees, then `.git` is a file and not a directory: This file references its own git directory within the main working tree. `$ git rev-parse --git-dir` will always return the directory where the `COMMIT_EDITMSG` file should be placed.
1 parent c3a4542 commit 994f3b0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

‎src/git/commit.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { spawn } from 'child_process';
1+
import { execSync, spawn } from 'child_process';
22

33
import path from 'path';
44

@@ -50,7 +50,11 @@ function commit (repoPath, message, options, done) {
5050
}
5151
});
5252
} else {
53-
const commitFilePath = path.join(repoPath, '/.git/COMMIT_EDITMSG');
53+
const gitDirPath = execSync(
54+
'git rev-parse --absolute-git-dir',
55+
{ cwd: repoPath, encoding: 'utf8' },
56+
).trim();
57+
const commitFilePath = path.join(gitDirPath, 'COMMIT_EDITMSG');
5458
try {
5559
const fd = openSync(commitFilePath, 'w');
5660
try {

0 commit comments

Comments
 (0)
Please sign in to comment.