Skip to content
This repository was archived by the owner on Mar 18, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ Type: `String`

Path to SSH key

#### shallowClone

Type: `Boolean`

Perform a shallow clone. Default: `false`.

### Usage example

```js
Expand All @@ -111,7 +117,8 @@ shipit: {
repositoryUrl: 'https://github.com/user/repo.git',
ignores: ['.git', 'node_modules'],
keepReleases: 2,
key: '/path/to/key'
key: '/path/to/key',
shallowClone: true
},
staging: {
servers: '[email protected]'
Expand Down
4 changes: 3 additions & 1 deletion lib/shipit.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ Shipit.prototype.initSshPool = function () {
*/

Shipit.prototype.initConfig = function (config) {

this.config = extend({
branch: 'master',
keepReleases: 5
keepReleases: 5,
shallowClone: false
}, config.options, config[this.stage]);
return this;
};
Expand Down
6 changes: 5 additions & 1 deletion tasks/deploy/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,13 @@ module.exports = function (grunt) {
*/

function fetch(cb) {
var fetchCommand = 'git fetch' +
(grunt.shipit.config.shallowClone ? ' --depth=1 ' : ' ') +
'shipit -p';

grunt.log.writeln('Fetching repository "%s"', grunt.shipit.config.repositoryUrl);
grunt.shipit.local(
'git fetch shipit -p',
fetchCommand,
{cwd: grunt.shipit.config.workspace},
function (err) {
if (err) return cb(err);
Expand Down
3 changes: 2 additions & 1 deletion test/unit/shipit.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ describe('Shipit', function () {
branch: 'master',
keepReleases: 5,
foo: 'bar',
kung: 'foo'
kung: 'foo',
shallowClone: false
});
});
});
Expand Down
27 changes: 27 additions & 0 deletions test/unit/tasks/deploy/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,31 @@ describe('deploy:fetch task', function () {
done();
});
});

it('should create workspace, create repo, checkout shallow and call sync', function (done) {
shipit.initConfig({
options: {
shallowClone: true
},
test: {
workspace: '/tmp/workspace',
repositoryUrl: 'git://website.com/user/repo'
}
});

runTask('deploy:fetch', function (err) {
if (err) return done(err);
expect(mkdirpMock).to.be.calledWith('/tmp/workspace');
expect(grunt.shipit.local).to.be.calledWith('git init', {cwd: '/tmp/workspace'});
expect(grunt.shipit.local).to.be.calledWith('git remote', {cwd: '/tmp/workspace'});
expect(grunt.shipit.local).to.be.calledWith(
'git remote add shipit git://website.com/user/repo',
{cwd: '/tmp/workspace'}
);
expect(grunt.shipit.local).to.be.calledWith('git fetch --depth=1 shipit -p', {cwd: '/tmp/workspace'});
expect(grunt.shipit.local).to.be.calledWith('git checkout master', {cwd: '/tmp/workspace'});
expect(grunt.shipit.local).to.be.calledWith('git branch --list master', {cwd: '/tmp/workspace'});
done();
});
});
});