Skip to content

Commit

Permalink
add --no-remote flag
Browse files Browse the repository at this point in the history
  • Loading branch information
lloyd committed Jun 1, 2012
1 parent 0129b96 commit f075d32
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
@@ -1,3 +1,6 @@
0.2.2 -
* add --[no-]remote flag to disable adding of git remotes

0.2.1 -
* debug zerigo DNS support, generalize secret format

Expand Down
31 changes: 21 additions & 10 deletions awsbox.js
Expand Up @@ -108,6 +108,9 @@ verbs['create'] = function(args) {
.describe('d', 'setup DNS via zerigo (requires ZERIGO_DNS_KEY in env)')
.describe('n', 'a short nickname for the VM.')
.describe('u', 'publically visible URL for the instance')
.describe('remote', 'add a git remote')
.boolean('remote')
.default('remote', true)
.check(function(argv) {
// parse/normalized typed in URL arguments
if (argv.u) argv.u = urlparse(argv.u).validate().originOnly().toString();
Expand Down Expand Up @@ -202,16 +205,8 @@ verbs['create'] = function(args) {
ssh.copyUpConfig(deets.ipAddress, config, function(err, r) {
checkErr(err);
console.log(" ... victory! server is accessible and configured");
git.addRemote(name, deets.ipAddress, function(err, r) {
if (err && /already exists/.test(err)) {
console.log("OOPS! you already have a git remote named '" + name + "'!");
console.log("to create a new one: git remote add <name> " +
"app@" + deets.ipAddress + ":git");
} else {
checkErr(err);
}
console.log(" ... and your git remote is all set up");

function postRemote() {
if (awsboxJson.packages) {
console.log(" ... finally, installing custom packages: " + awsboxJson.packages.join(', '));
}
Expand All @@ -232,7 +227,23 @@ verbs['create'] = function(args) {
}
});
});
});
}

if (!opts.remote) {
postRemote();
} else {
git.addRemote(name, deets.ipAddress, function(err, r) {
if (err && /already exists/.test(err)) {
console.log("OOPS! you already have a git remote named '" + name + "'!");
console.log("to create a new one: git remote add <name> " +
"app@" + deets.ipAddress + ":git");
} else {
checkErr(err);
}
console.log(" ... and your git remote is all set up");
postRemote();
});
}
});
});
});
Expand Down
4 changes: 1 addition & 3 deletions lib/git.js
Expand Up @@ -4,7 +4,7 @@ spawn = child_process.spawn,
path = require('path');

exports.addRemote = function(name, host, cb) {
var cmd = 'git remote add ' + name + ' app@'+ host + ':git';
var cmd = 'git remote add "' + name + '" app@'+ host + ':git';
child_process.exec(cmd, cb);
};

Expand Down Expand Up @@ -39,7 +39,6 @@ exports.currentSHA = function(dir, cb) {
cb = dir;
dir = path.join(__dirname, '..', '..');
}
console.log(dir);

var p = spawn('git', [ 'log', '--pretty=%h', '-1' ], {
env: { GIT_DIR: path.join(dir, ".git") }
Expand All @@ -49,7 +48,6 @@ exports.currentSHA = function(dir, cb) {
buf += d;
});
p.on('exit', function(code, signal) {
console.log(buf);
var gitsha = buf.toString().trim();
if (gitsha && gitsha.length === 7) {
return cb(null, gitsha);
Expand Down

0 comments on commit f075d32

Please sign in to comment.