Permalink
Browse files

compute the git port properly

  • Loading branch information...
1 parent 865b25d commit ff4cfc837a7abb7d00e7b36f4c49f1e720a992b6 @substack committed Aug 1, 2012
Showing with 17 additions and 5 deletions.
  1. +16 −4 bin/deploy.js
  2. +1 −1 test/commands.js
View
@@ -33,10 +33,22 @@ p.hub(function (hub) {
});
function deploy (hub, opts) {
- var ref = 'http://'
- + (argv.secret ? 'git:' + encodeURIComponent(argv.secret) + '@' : '')
- + argv.hub.split(':')[0]
- ;
+ var ref = (function () {
+ var auth = argv.secret
+ ? 'git:' + encodeURIComponent(argv.secret) + '@'
+ : ''
+ ;
+ var uri = argv.git;
+ if (!uri) {
+ var xs = argv.hub.split(':');
+ var gitPort = argv.gitPort
+ || argv.gitport
+ || parseInt(xs[1], 10) + 1
+ ;
+ uri = xs[0] + ':' + gitPort;
+ }
+ return 'http://' + auth + uri;
+ })();
git.push(ref, function (err) {
if (err) {
View
@@ -12,7 +12,7 @@ var dir = {
gitRepo: basedir +'/gitRepo',
};
var procs = { hub : null, drone : [] };
-var port = Math.floor(Math.random() * ((1<<16) - 1e4)) + 1e4;
+var port = Math.floor(Math.random() * 5e4 - 1e4) + 1e4;
dir.drone.concat(dir.hub).forEach(function (x) {
mkdirp.sync(x);

0 comments on commit ff4cfc8

Please sign in to comment.