diff --git a/gulpfile.js b/gulpfile.js index f4959161e..752430613 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -770,3 +770,51 @@ gulp.task('release', gulp.series(['build', 'typings', function() { // The default task builds Blockly. gulp.task('default', gulp.series(['build'])); + +// Stash current state, check out develop, and sync with google/blockly. +gulp.task('syncDevelop', function(done) { + execSync('git stash save -m "Stash for sync"', { stdio: 'inherit' }); + execSync('git checkout develop', { stdio: 'inherit' }); + execSync('git pull https://github.com/google/blockly.git develop', + { stdio: 'inherit' }); + execSync('git push origin develop', { stdio: 'inherit' }); + done(); +}); + +// Helper function: get a name for a rebuild branch. Format: rebuild_mm_dd_yyyy. +function getRebuildBranchName() { + var date = new Date(); + var mm = date.getMonth() + 1; // Month, 0-11 + var dd = date.getDate(); // Day of the month, 1-31 + var yyyy = date.getFullYear(); + return 'rebuild_' + mm + '_' + dd + '_' + yyyy; +} + +// Stash and make a new branch for a rebuild. +gulp.task('make-rebuild-branch', function(done) { + execSync('git stash save -m "Stash for rebuild"', { stdio: 'inherit' }); + var branchName = getRebuildBranchName(); + console.log('make-rebuild-branch: creating branch ' + branchName); + execSync('git checkout -b ' + branchName, { stdio: 'inherit' }); + done(); +}); + +// Commit and push the current rebuild branch. +gulp.task('push-rebuild-branch', function(done) { + console.log('push-rebuild-branch: committing rebuild'); + execSync('git commit -am "Rebuild"', { stdio: 'inherit' }); + var branchName = getRebuildBranchName(); + execSync('git push origin ' + branchName, { stdio: 'inherit' }); + console.log('Branch ' + branchName + ' pushed to GitHub.'); + console.log('Next step: create a pull request against develop.'); + done(); +}); + +// Recompile and push to origin. +gulp.task('recompile', gulp.series[ + 'syncDevelop', + 'make-rebuild-branch' + 'build', + 'push-rebuild-branch' + ] +);