Skip to content

Commit b346a45

Browse files
committed
Normalize commit template paths on Windows
1 parent 89be380 commit b346a45

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/git-shell-out-strategy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ export default class GitShellOutStrategy {
454454
// if no user is specified, fall back to using the home directory.
455455
return `${user ? path.join(path.dirname(homeDir), user) : homeDir}/`;
456456
});
457+
templatePath = toNativePathSep(templatePath);
457458

458459
if (!path.isAbsolute(templatePath)) {
459460
templatePath = path.join(this.workingDir, templatePath);

test/git-strategies.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ import * as reporterProxy from '../lib/reporter-proxy';
165165
});
166166

167167
it('replaces ~ with your home directory', async function() {
168-
await git.setConfig('commit.template', `~${path.sep}does-not-exist.txt`);
168+
// Fun fact: even on Windows, git does not accept "~\does-not-exist.txt"
169+
await git.setConfig('commit.template', '~/does-not-exist.txt');
169170
await assert.isRejected(
170171
git.fetchCommitMessageTemplate(),
171172
`Invalid commit template path set in Git config: ${path.join(os.homedir(), 'does-not-exist.txt')}`,
@@ -174,7 +175,7 @@ import * as reporterProxy from '../lib/reporter-proxy';
174175

175176
it("replaces ~user with user's home directory", async function() {
176177
const expectedFullPath = path.join(path.dirname(os.homedir()), 'nope/does-not-exist.txt');
177-
await git.setConfig('commit.template', `~nope${path.sep}does-not-exist.txt`);
178+
await git.setConfig('commit.template', '~nope/does-not-exist.txt');
178179
await assert.isRejected(
179180
git.fetchCommitMessageTemplate(),
180181
`Invalid commit template path set in Git config: ${expectedFullPath}`,

0 commit comments

Comments
 (0)