Skip to content
This repository has been archived by the owner on Mar 18, 2018. It is now read-only.

Commit

Permalink
Added updateSubmodules option for fetch task
Browse files Browse the repository at this point in the history
  • Loading branch information
feiin committed Apr 20, 2016
1 parent e637e5e commit d5dc91c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
node_modules/
.idea/
21 changes: 21 additions & 0 deletions tasks/deploy/fetch.js
Expand Up @@ -23,6 +23,7 @@ module.exports = function (gruntOrShipit) {
.then(checkout)
.then(reset)
.then(merge)
.then(updateSubmodules)
.then(function () {
shipit.emit('fetched');
});
Expand Down Expand Up @@ -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'));
});
}
}
};
20 changes: 20 additions & 0 deletions test/unit/tasks/deploy/fetch.js
Expand Up @@ -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();
});
});
});

0 comments on commit d5dc91c

Please sign in to comment.