Skip to content
This repository was archived by the owner on Nov 18, 2021. It is now read-only.
Open
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: 6 additions & 3 deletions bin/gistup
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ queue(1)
.defer(createGist, settings.token)
.await(function(error, _, _, _, id) {
unless(error)
.defer(gitRemoteAdd, id)
.defer(gitRemoteAdd, id, settings)
.defer(gitPush)
.defer(openBrowser, argv.open && settings.open, id)
.await(unless);
Expand Down Expand Up @@ -175,8 +175,11 @@ function createGist(token, callback) {
});
}

function gitRemoteAdd(id, callback) {
child.exec("git remote add --track master " + quote.single(argv.remote) + " [email protected]:" + id + ".git", function(error, stdout, stderr) {
function gitRemoteAdd(id, settings, callback) {
url = "[email protected]:" + id + ".git"; // default
if (/^https$/i.test(settings.protocol)) url = "https://" + settings.user + ":" + settings.token + "@gist.github.com/" + id + ".git";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

settings.user is not needed, you can simply construct the URL as: https://[email protected]


child.exec("git remote add --track master " + quote.single(argv.remote) + " " + url, function(error, stdout, stderr) {
if (!error && stderr) process.stderr.write(stderr), error = new Error("git remote failed.");
if (!error && stdout) process.stdout.write(stdout);
callback(error);
Expand Down