Skip to content

Commit

Permalink
fix: 🐛 Fix COMMIT_EDITMSG in bare repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
kamack38 committed Apr 18, 2022
1 parent 59a4fb8 commit 008ee31
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const createState = require('./createState');
const runInteractiveQuestions = require('./runInteractiveQuestions');
const runNonInteractiveMode = require('./runNonInteractiveMode');
const formatCommitMessage = require('./formatCommitMessage');
const getGitRootDir = require('./util/getGitRootDir');
const getGitDir = require('./util/getGitDir');

// eslint-disable-next-line no-process-env
const executeCommand = (command, env = process.env) => {
Expand Down Expand Up @@ -89,7 +89,7 @@ const main = async () => {
}
}

const commitMsgFile = join(getGitRootDir(), '.git', 'COMMIT_EDITMSG');
const commitMsgFile = join(getGitDir(), 'COMMIT_EDITMSG');

const command = shellescape([
'git',
Expand Down
12 changes: 12 additions & 0 deletions lib/util/getGitDir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const {execSync} = require('child_process');

const getGitDir = () => {
const devNull = process.platform === 'win32' ? ' nul' : '/dev/null';
const dir = execSync('git rev-parse --absolute-git-dir 2>' + devNull)
.toString()
.trim();

return dir;
};

module.exports = getGitDir;

0 comments on commit 008ee31

Please sign in to comment.