From 07d6f33db9b09e22368fd0f5f07f0759c912d984 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Tue, 15 Oct 2019 15:05:50 -0600 Subject: [PATCH 1/4] Rebuild task in gulp. --- gulpfile.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) 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' + ] +); From 90f529603ee3d81b90913f98175cb06fd6ef4032 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Wed, 16 Oct 2019 11:17:59 -0600 Subject: [PATCH 2/4] Review feedback --- gulpfile.js | 48 +++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 752430613..32fe0cfef 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -772,7 +772,7 @@ gulp.task('release', gulp.series(['build', 'typings', function() { gulp.task('default', gulp.series(['build'])); // Stash current state, check out develop, and sync with google/blockly. -gulp.task('syncDevelop', function(done) { +gulp.task('git-sync-develop', 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', @@ -788,33 +788,27 @@ function getRebuildBranchName() { 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' +gulp.task('recompile', gulp.series([ + 'git-sync-develop', + 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(); + }, 'build', - '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(); + } + ]) ); From 17f47ee2cb2a42adbd6ab55c67e820caf956154a Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Wed, 16 Oct 2019 11:29:54 -0600 Subject: [PATCH 3/4] Make git-sync-master as well as git-sync-develop --- gulpfile.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 32fe0cfef..93e9ed9ab 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -771,15 +771,25 @@ gulp.task('release', gulp.series(['build', 'typings', function() { // The default task builds Blockly. gulp.task('default', gulp.series(['build'])); + +// Stash current state, check out the named branch, and sync with +// google/blockly. +function syncBranch(branchName) { + return function(done) { + execSync('git stash save -m "Stash for sync"', { stdio: 'inherit' }); + execSync('git checkout ' + branchName, { stdio: 'inherit' }); + execSync('git pull https://github.com/google/blockly.git ' + branchName, + { stdio: 'inherit' }); + execSync('git push origin ' + branchName, { stdio: 'inherit' }); + done(); + } +} + // Stash current state, check out develop, and sync with google/blockly. -gulp.task('git-sync-develop', 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(); -}); +gulp.task('git-sync-develop', syncBranch('develop')); + +// Stash current state, check out master, and sync with google/blockly. +gulp.task('git-sync-master', syncBranch('master')); // Helper function: get a name for a rebuild branch. Format: rebuild_mm_dd_yyyy. function getRebuildBranchName() { From 90f6948c275ffbe8b316c9a7235bab09a9f031eb Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Thu, 17 Oct 2019 10:21:55 -0600 Subject: [PATCH 4/4] Remove unnecessary stash --- gulpfile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 93e9ed9ab..b6bc06afc 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -804,7 +804,6 @@ function getRebuildBranchName() { gulp.task('recompile', gulp.series([ 'git-sync-develop', 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' });