From d5dc91c30ed9a62f4676985723beaccc1fca5c6a Mon Sep 17 00:00:00 2001 From: feiin Date: Wed, 20 Apr 2016 12:50:47 +0800 Subject: [PATCH 1/2] Added updateSubmodules option for fetch task --- .gitignore | 1 + tasks/deploy/fetch.js | 21 +++++++++++++++++++++ test/unit/tasks/deploy/fetch.js | 20 ++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/.gitignore b/.gitignore index c2658d7..d35bbf7 100755 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules/ +.idea/ \ No newline at end of file diff --git a/tasks/deploy/fetch.js b/tasks/deploy/fetch.js index 4a7da1d..9656248 100644 --- a/tasks/deploy/fetch.js +++ b/tasks/deploy/fetch.js @@ -23,6 +23,7 @@ module.exports = function (gruntOrShipit) { .then(checkout) .then(reset) .then(merge) + .then(updateSubmodules) .then(function () { shipit.emit('fetched'); }); @@ -172,5 +173,25 @@ module.exports = function (gruntOrShipit) { shipit.log(chalk.green('Branch merged.')); }); } + + /** + * update submodules + */ + + function updateSubmodules() { + + if (!shipit.config.updateSubmodules) { + return Promise.resolve(); + } + + shipit.log('Updating submodules.'); + return shipit.local( + 'git submodule update --init --recursive', + {cwd: shipit.config.workspace} + ) + .then(function () { + shipit.log(chalk.green('Submodules updated')); + }); + } } }; diff --git a/test/unit/tasks/deploy/fetch.js b/test/unit/tasks/deploy/fetch.js index 12c2532..23c9a0a 100644 --- a/test/unit/tasks/deploy/fetch.js +++ b/test/unit/tasks/deploy/fetch.js @@ -73,4 +73,24 @@ describe('deploy:fetch task', function () { done(); }); }); + + it('should create workspace, create repo, checkout and call sync, update submodules', function (done) { + shipit.config.updateSubmodules = true; + + shipit.start('deploy:fetch', function (err) { + if (err) return done(err); + expect(mkdirpMock).to.be.calledWith('/tmp/workspace'); + expect(shipit.local).to.be.calledWith('git init', {cwd: '/tmp/workspace'}); + expect(shipit.local).to.be.calledWith('git remote', {cwd: '/tmp/workspace'}); + expect(shipit.local).to.be.calledWith( + 'git remote add shipit git://website.com/user/repo', + {cwd: '/tmp/workspace'} + ); + expect(shipit.local).to.be.calledWith('git fetch shipit --prune && git fetch shipit --prune "refs/tags/*:refs/tags/*"', {cwd: '/tmp/workspace'}); + expect(shipit.local).to.be.calledWith('git checkout master', {cwd: '/tmp/workspace'}); + expect(shipit.local).to.be.calledWith('git branch --list master', {cwd: '/tmp/workspace'}); + expect(shipit.local).to.be.calledWith('git submodule update --init --recursive', {cwd: '/tmp/workspace'}); + done(); + }); + }); }); From d398b2cb96207f3b8be15b2b8bca77a7e075ad02 Mon Sep 17 00:00:00 2001 From: feiin Date: Wed, 20 Apr 2016 13:03:59 +0800 Subject: [PATCH 2/2] add updateSubmodules options --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 6d515d5..081e434 100755 --- a/README.md +++ b/README.md @@ -122,6 +122,14 @@ Type: `Boolean` Perform a shallow clone. Default: `false`. +###updateSubmodules + +Type: Boolean + +Update submodules. Default: `false`. + + + ### gitLogFormat Type: `String`