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

Commit

Permalink
Merge pull request #115 from feiin/master
Browse files Browse the repository at this point in the history
Added updateSubmodules option for fetch task
  • Loading branch information
gregberge committed Apr 30, 2016
2 parents 1afa2df + d398b2c commit 2e3b735
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
.idea/
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ Type: `Boolean`

Perform a shallow clone. Default: `false`.

###updateSubmodules

Type: Boolean

Update submodules. Default: `false`.



### gitLogFormat

Type: `String`
Expand Down
21 changes: 21 additions & 0 deletions tasks/deploy/fetch.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 2e3b735

Please sign in to comment.