From c042fc444a858385c91a20a37cc8c29df478af6c Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Wed, 14 Oct 2015 03:03:59 +0200 Subject: [PATCH 1/4] Don't assume options.remote is 'origin' --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 708467d..46a35d4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -39,7 +39,7 @@ function getRepo(options) { if (options.repo) { return Q.resolve(options.repo); } else { - return getRemoteUrl(process.cwd(), 'origin'); + return getRemoteUrl(process.cwd(), options.remote); } } From 11887822055adb36bda6f6073ee606897037ebdd Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Wed, 14 Oct 2015 03:04:28 +0200 Subject: [PATCH 2/4] Print correct error message when remote != 'origin' --- lib/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 46a35d4..d6a0a00 100644 --- a/lib/index.js +++ b/lib/index.js @@ -29,8 +29,8 @@ function getRemoteUrl(dir, remote) { }) .fail(function(err) { return Q.reject(new Error( - 'Failed to get remote.origin.url (task must either be run in a ' + - 'git repository with a configured origin remote or must be ' + + '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).')); }); } From dfbdfe08f3c02793c39eecfb4e9f5c19f17afa63 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Mon, 9 Nov 2015 15:10:54 +0000 Subject: [PATCH 3/4] 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).')); }); } From ce5368f8a1fe62f618d5b4e745c86695b4223169 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Wed, 2 Mar 2016 08:40:48 -0700 Subject: [PATCH 4/4] Document the remote option --- bin/gh-pages | 3 +++ readme.md | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/bin/gh-pages b/bin/gh-pages index 1496e93..e5305d3 100755 --- a/bin/gh-pages +++ b/bin/gh-pages @@ -15,6 +15,8 @@ program .option('-x, --silent', 'Do not output the repository url') .option('-b, --branch ', 'name of the branch you\'ll be pushing to', 'gh-pages') + .option('-o, --remote ', + 'The name of the remote', 'origin') .option('-m, --message ', 'commit message', 'Updates') .option('-t, --dotfiles', 'Include dotfiles') @@ -30,6 +32,7 @@ ghpages.publish(path.join(process.cwd(), program.dist), { message: program.message, dotfiles: !!program.dotfiles, add: !!program.add, + remote: program.remote, push: !program.noPush, logger: function(message) { process.stderr.write(message + '\n'); diff --git a/readme.md b/readme.md index 5cbfde1..5256535 100644 --- a/readme.md +++ b/readme.md @@ -149,6 +149,24 @@ ghpages.publish(path.join(__dirname, 'build'), { ``` +#### options.remote + * type: `string` + * default: `'origin'` + +The name of the remote you'll be pushing to. The default is your `'origin'` remote, but this can be configured to push to any remote. + +Example use of the `remote` option: + +```js +/** + * This task pushes to the `gh-pages` branch of of your `upstream` remote. + */ +ghpages.publish(path.join(__dirname, 'build'), { + remote: 'upstream' +}, callback); +``` + + #### options.tag * type: `string` * default: `''`