Clone using options.remote as the origin name

This commit is contained in:
Marco Castelluccio 2015-11-09 15:10:54 +00:00 committed by Tim Schaub
parent 1188782205
commit dfbdfe08f3
2 changed files with 6 additions and 5 deletions

View file

@ -99,13 +99,14 @@ exports.clone = function clone(repo, dir, branch, options) {
return Q.resolve();
} else {
return fs.makeTree(path.dirname(path.resolve(dir))).then(function() {
var args = ['clone', repo, dir, '--branch', branch, '--single-branch'];
var args = ['clone', repo, dir, '--branch', branch, '--single-branch',
'--origin', options.remote];
if (options.depth) {
args.push('--depth', options.depth);
}
return spawn(git, args).fail(function(err) {
// try again without banch options
return spawn(git, ['clone', repo, dir]);
return spawn(git, ['clone', repo, dir, '--origin', options.remote]);
});
});
}

View file

@ -29,9 +29,9 @@ function getRemoteUrl(dir, remote) {
})
.fail(function(err) {
return Q.reject(new Error(
'Failed to get remote.' + remote + '.url (task must either be run in a ' +
'git repository with a configured ' + remote + ' remote or must be ' +
'configured with the "repo" option).'));
'Failed to get remote.' + remote + '.url (task must either be ' +
'run in a git repository with a configured ' + remote + ' remote ' +
'or must be configured with the "repo" option).'));
});
}