Skip to content

Commit e87376f

Browse files
committed
fix(commit): fixes Windows multiline commits
Windows git command line will not handle multiline commit messages passed to it regularly. Instead, we must add multiple -m arguments, one for each line. I landed this feature in git-gulp previously but we needed to detect the os and pass an array of lines to git-gulp in order for it to use this method. This change makes sure that we use the -m method when commiting on windows.
1 parent 622e56c commit e87376f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "src/index.js",
66
"scripts": {
77
"check-coverage": "istanbul check-coverage --statements 80 --branches 80 --functions 80 --lines 80 ",
8-
"commit": "git-cz",
8+
"commit": "node bin/git-cz",
99
"build": "babel src --out-dir dist",
1010
"build:watch": "babel --watch src --out-dir dist",
1111
"prepublish": "npm run build",

src/git/commit.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os from 'os';
12
import git from 'gulp-git';
23
import gulp from 'gulp';
34
import dedent from 'dedent';
@@ -11,12 +12,21 @@ export { commit };
1112
function commit(sh, repoPath, message, options, done) {
1213

1314
var alreadyEnded = false;
15+
let dedentedMessage = dedent(message);
16+
let operatingSystemNormalizedMessage;
17+
// On windows we must use an array in gulp-git instead of a string because
18+
// command line parsing works differently
19+
if(os.platform()=="win32") {
20+
operatingSystemNormalizedMessage = dedentedMessage.split(/\r?\n/);
21+
} else {
22+
operatingSystemNormalizedMessage = dedentedMessage;
23+
}
1424

1525
// Get a gulp stream based off the config
1626
gulp.src(repoPath)
1727

1828
// Format then commit
19-
.pipe(git.commit(dedent(message), options))
29+
.pipe(git.commit(operatingSystemNormalizedMessage, options))
2030

2131
// Write progress to the screen
2232
.on('data',function(data) {

0 commit comments

Comments
 (0)