Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: πŸ› wrong COMMIT_EDITMSG on Windows in Cygwin env #646

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {spawn, execSync} = require('child_process');
const fs = require('fs');
const {join} = require('path');
const path = require('path');
const shellescape = require('any-shell-escape');
const signale = require('signale');
const parseArgs = require('./parseArgs');
Expand Down Expand Up @@ -89,7 +89,7 @@ const main = async () => {
}
}

const commitMsgFile = join(getGitDir(), 'COMMIT_EDITMSG');
const commitMsgFile = path.posix.join(getGitDir(), 'COMMIT_EDITMSG');

const command = shellescape([
'git',
Expand Down
4 changes: 1 addition & 3 deletions lib/util/getGitDir.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
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()
const dir = execSync('git rev-parse --absolute-git-dir', {encoding: 'utf8'})
.trim();

return dir;
Expand Down
9 changes: 0 additions & 9 deletions test/__snapshots__/cli.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,3 @@ exports[`git-cz --help 1`] = `

"
`;

exports[`git-cz --non-interactive 1`] = `
"Running in dry mode.
Will execute command:
git commit --file '.git/COMMIT_EDITMSG'
Message:
chore: πŸ€– automated commit
"
`;
9 changes: 8 additions & 1 deletion test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ test('git-cz --version', async () => {
test('git-cz --non-interactive', async () => {
const {getResult} = runCLI(['--non-interactive', '--dry-run']);

const quote = process.platform === 'win32' ? '"' : '\'';
const result = await getResult();

expect(result).toMatchSnapshot();
expect(result).toBe(`\
Running in dry mode.
Will execute command:
git commit --file ${quote}.git/COMMIT_EDITMSG${quote}
Message:
chore: πŸ€– automated commit
`);
});