gulp-tag-version icon indicating copy to clipboard operation
gulp-tag-version copied to clipboard

git.push after tagging

Open djindjic opened this issue 10 years ago • 5 comments

I cant push code to repo after taggin. Here is my gulpfile code:

gulp.task('deploy', function(){
  gulp.src(['./package.json'])
    .pipe(bump({type:'patch'}))
    .pipe(gulp.dest('./'))
    .pipe(git.commit('bumps package version'))
    .pipe(filter('package.json'))
    .pipe(tag_version())

    .pipe(git.push('origin', 'master', {args: " --tags"}, function (err) {
      if (err) throw err;
    }));
});

end I've had this error:

stream.js:79
    dest.end();
         ^
TypeError: Object #<ChildProcess> has no method 'end'
    at Stream.onend (stream.js:79:10)
    at Stream.emit (events.js:117:20)

djindjic avatar Dec 24 '14 11:12 djindjic

(crickets)

Try this, if you haven't already:

gulp.task('deploy', function(){

  function cb(obj) {
    var stream = new require('stream').Transform({objectMode: true});
    stream._transform = function(file, unused, callback) {
      obj();
      callback(null, file);
    };
    return stream;
  }

  gulp.src(['./package.json'])
    .pipe(bump({type:'patch'}))
    .pipe(gulp.dest('./'))
    .pipe(git.commit('bumps package version'))
    .pipe(filter('package.json'))
    .pipe(tag_version())
    .pipe(cb(function() {
      git.push('origin','master', {args: " --tags"}, function (err) {
        if (err) throw err;
      });
    }));
});

kfitzgerald avatar Mar 18 '15 20:03 kfitzgerald

I had the same problem as @djindjic and your workaround seems to work - but now I'm facing another (probably related) issue. When I execute the deploy tasks it seems like there is some kind of race condition because sometimes the git push origin master --tags pushes the commit with the version bump but misses the tag. As an example you can use the github-push-tag-repo. The first two tags&pushes worked fine but as you can see the commit to bump the version to 1.0.3 was pushed but the tag wasn't (although it exists locally)

klausbayrhammer avatar Jul 23 '15 15:07 klausbayrhammer

@klausbayrhammer Oh, that sounds like something worth opening an issue. I have never tried adding git push to the gulpfile, as I prefer to have control over this step just to be on the safe side. It is possible that tagging worked asynchronously, thus late. That for sure deserves an issue and investigation :(

ikari-pl avatar Jul 24 '15 07:07 ikari-pl

I am actually not strong enough with gulp-fu (especially that I haven't written much gulp code since I wrote this plugin) and started wondering... — @kfitzgerald can you explain in Simple English, how the cb solution works? I understand the problem it solves, but I'm not sure I understand the way it does it.

ikari-pl avatar Jul 24 '15 07:07 ikari-pl

Derp. Forgot to follow up, @ikari-pl. Here's the Simple English on that blob I posted five months ago:

The cb function is basically its own gulp plugin, so to speak, which was ripped from the the gulp-callback module.

At a deeper level, cb takes an argument obj which should be a function expression. The function cb creates a stream transformer, that when it comes time to transform, it fires the obj expression and finishes without actually manipulating the stream in anyway. The cb function returns stream object, so that gulp may pipe its payload through it and proceed down the funnel.

Hope that helps!

kfitzgerald avatar Aug 26 '15 14:08 kfitzgerald