Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wkunert committed Aug 21, 2020
1 parent c3a4542 commit 994f3b0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/git/commit.js
@@ -1,4 +1,4 @@
import { spawn } from 'child_process';
import { execSync, spawn } from 'child_process';

import path from 'path';

Expand Down Expand Up @@ -50,7 +50,11 @@ function commit (repoPath, message, options, done) {
}
});
} else {
const commitFilePath = path.join(repoPath, '/.git/COMMIT_EDITMSG');
const gitDirPath = execSync(
'git rev-parse --absolute-git-dir',
{ cwd: repoPath, encoding: 'utf8' },
).trim();
const commitFilePath = path.join(gitDirPath, 'COMMIT_EDITMSG');
try {
const fd = openSync(commitFilePath, 'w');
try {
Expand Down

0 comments on commit 994f3b0

Please sign in to comment.