From dfbdfe08f3c02793c39eecfb4e9f5c19f17afa63 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Mon, 9 Nov 2015 15:10:54 +0000 Subject: [PATCH] Clone using options.remote as the origin name --- lib/git.js | 5 +++-- lib/index.js | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/git.js b/lib/git.js index af3c8b7..414e0bd 100644 --- a/lib/git.js +++ b/lib/git.js @@ -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]); }); }); } diff --git a/lib/index.js b/lib/index.js index d6a0a00..024191a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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).')); }); }