2
votes

I'm trying to push to my remote repository using the gulp-git module from npm. The add & commit portion runs fine, but it runs into a stream error when trying to perform the remote push.

bump: function () {
  var branch = argv.branch || 'development';
  fs.readFile('./package.json', function (err, data) {
    if (err) { return ; }
    return gulp.src(['./package.json', './bower.json'])
      .pipe(git.add())
      .pipe(git.commit('chore(core): bump to ' + JSON.parse(data).version))
      .pipe(git.push('origin', branch, function(err) {
        if(err) throw (err);
      }));
  });
}

The stack trace:

C:\src\git\ig\node_modules\gulp-git\node_modules\through2\node_modules\readable-stream\lib_stream_readable.js:623

var written = dest.write(chunk);

                ^

TypeError: undefined is not a function at write (C:\src\git\ig\node_modules\gulp-git\node_modules\through2\node_modules\readable-stream\lib_stream_readable.js:623:24) at flow (C:\src\git\ig\node_modules\gulp-git\node_modules\through2\node_modules\readable-stream\lib_stream_readable.js:632:7) at DestroyableTransform.pipeOnReadable (C:\src\git\ig\node_modules\gulp-git\node_modules\through2\node_modules\readable-stream\lib_stream_readable.js:664:5) at DestroyableTransform.emit (events.js:104:17) at emitReadable_ (C:\src\git\ig\node_modules\gulp-git\node_modules\through2\node_modules\readable-stream\lib_stream_readable.js:448:10) at emitReadable (C:\src\git\ig\node_modules\gulp-git\node_modules\through2\node_modules\readable-stream\lib_stream_readable.js:444:5) at readableAddChunk (C:\src\git\ig\node_modules\gulp-git\node_modules\through2\node_modules\readable-stream\lib_stream_readable.js:187:9) at DestroyableTransform.Readable.push (C:\src\git\ig\node_modules\gulp-git\node_modules\through2\node_modules\readable-stream\lib_stream_readable.js:149:10) at DestroyableTransform.Transform.push (C:\src\git\ig\node_modules\gulp-git\node_modules\through2\node_modules\readable-stream\lib_stream_transform.js:145:32) at Array.forEach (native)

I'm running gulp-git version 1.6.0. It looks like they are at 1.7.0. Maybe the upgrade path would help however this seems like a pretty standard usage of the command, so I think it's something I'm doing wrong.

1
Are you sure the branch name is correct?Matthew Herbst
@MatthewHerbst - turns out that the issue was trying to do git.push while it was in a stream. See answer below if you're curious.rawkfist0215

1 Answers

4
votes

With help from stevelacy (the project admin) I was able to make it work with this code change:

.pipe(git.commit('chore(core): bump to ' + JSON.parse(data).version))
.on('end', function() {
  git.push('origin', branch, function(err) {
    if(err) throw (err);
  });

});

It turns out that the git push command cannot be done from a stream as of yet.