'use strict';
var util = require('util');
var yeoman = require('yeoman-generator');
var Step = require('step');
var spawn = require('child_process').spawn;
var git = require('gift');
require('colors');

var UpdateGenerator = module.exports = function UpdateGenerator(args, options, config) {
  // By calling `NamedBase` here, we get the argument to the subgenerator call
  // as `this.name`.
  yeoman.generators.Base.apply(this, arguments);

};

util.inherits(UpdateGenerator, yeoman.generators.Base);

UpdateGenerator.prototype.gitUpdate = function gitUpdate() {
	var cb = this.async();

	console.log('git update');
	var repo = git('./');

	function checkoutSeed(cb) {
		var checkedout = false;
		Step(function() {
			repo.branches(this);
		}, function(err, branches) {
			if (err) throw err;

			if (branches.indexOf('seed') >= 0) {
				repo.checkout('seed', this);
			} else {
				repo.checkout('-t origin/seed', this)
			}
		}, function(err) {
			cb(err);
		});
	}


	Step(function() {
		console.log('grabbing changes to pup...'.green)
		checkoutSeed(this);
	}, function(err) {
		if (err) throw err;
		repo.git('pull', {}, ['https://github.com/themang/pup', 'master'], this);
	}, function(err) {
		if (err) throw err;
		console.log('merging changes...'.green);
		repo.checkout('master', this);
	}, function(err) {
		if (err) throw err;
		repo.git('merge', {}, ['seed'], this);
	}, function(err) {
		if (err) throw err;
		cb();
	});
  
};

@@ -176,16 +176,89 @@
 gift');%0A
+var _ = require('underscore');%0Avar exec = require('child_process').exec;%0A
 require(
@@ -269,16 +269,17 @@
 ors');%0A%0A
+%0A
 var Upda
@@ -660,36 +660,8 @@
 );%0A%0A
-%09console.log('git update');%0A
 %09var
@@ -837,45 +837,52 @@
 rr;%0A
-%0A
 %09%09%09if (
-branches.indexOf('seed') %3E= 0
+_.findWhere(branches, %7Bname: 'seed'%7D)
 ) %7B%0A
@@ -1156,31 +1156,23 @@
 ;%0A%09%09
-repo.git('
+exec('git 
 pull
-', %7B%7D, %5B'
+ 
 http
@@ -1201,20 +1201,43 @@
 /pup
-', '
+ 
 master'
-%5D
+, %7BmaxBuffer: 10000 * 1024%7D
 , th
@@ -1407,38 +1407,56 @@
 ;%0A%09%09
-repo.git('
+exec('git 
 merge
-', %7B%7D, %5B'seed'%5D
+ seed', %7BmaxBuffer: 10000 * 1024%7D
 , th

increase buffers