Permalink
Browse files

Fix https clone, and support http also.

  • Loading branch information...
1 parent ee5631e commit 4c56e6dbe3fe178c0ba5e59df72ddb2bcf23c351 @killfill killfill committed Dec 18, 2013
Showing with 15 additions and 14 deletions.
  1. +4 −3 config/config.html
  2. +6 −6 lib/index.js
  3. +2 −2 webapp.js
  4. +3 −3 worker.js
View
@@ -3,13 +3,14 @@
<input required
type="text"
ng-model="config.url"
- ng-pattern="/git:\/\/.+?/"
+ ng-pattern="/(git|http|https):\/\/.+?/"
placeholder="git://example.com/my/repo.git">
</label>
<div class="auth-type">
<h3>Auth type</h3>
<div class="btn-group">
<div class="btn" ng-model="config.auth.type" required btn-radio="'ssh'">SSH</div>
+ <div class="btn" ng-model="config.auth.type" required btn-radio="'http'">HTTP</div>
<div class="btn" ng-model="config.auth.type" required btn-radio="'https'">HTTPS</div>
</div>
<div ng-show="config.auth.type === 'ssh'">
@@ -29,8 +30,8 @@
</div>
</div>
</div>
- <div ng-show="config.auth.type === 'https'">
- <span class="help-text">Https auth</span>
+ <div ng-show="config.auth.type.indexOf('http') > -1">
+ <span class="help-text">Http(s) auth</span>
<label>
<input type="text"
ng-required="config.auth.type === 'https'"
View
@@ -6,7 +6,7 @@ var gitane = require('gitane')
module.exports = {
gitUrl: gitUrl,
sshUrl: sshUrl,
- httpsUrl: httpsUrl,
+ httpUrl: httpUrl,
gitCmd: gitCmd,
gitaneCmd: gitaneCmd,
processBranches: processBranches,
@@ -23,7 +23,7 @@ function shellEscape(one) {
// returns [real, safe] urls
function gitUrl(config) {
- return (config.auth.type === 'ssh' ? sshUrl : httpsUrl)(config)
+ return (config.auth.type === 'ssh' ? sshUrl : httpUrl)(config)
}
function sshUrl(config) {
@@ -32,10 +32,10 @@ function sshUrl(config) {
return [url, url]
}
-function httpsUrl(config) {
+function httpUrl(config) {
var base = config.url.split('//')[1]
- , url = 'https://' + config.auth.username + ':' + config.auth.password + '@' + base
- , safe = 'https://[username]:[password]@' + base
+ , url = config.auth.type + '://' + config.auth.username + ':' + config.auth.password + '@' + base
+ , safe = config.auth.type + '://[username]:[password]@' + base
return [url, safe]
}
@@ -91,7 +91,7 @@ function getBranches(config, privkey, done) {
processBranches(stdout, done)
})
} else {
- exec('git ls-remote -h ' + sshUrl(config)[0], function (err, stdout, stderr) {
+ exec('git ls-remote -h ' + httpUrl(config)[0], function (err, stdout, stderr) {
if (err) return done(err)
processBranches(stdout, done)
})
View
@@ -7,7 +7,7 @@ function sanitizeConfig(config) {
url: config.url,
display_url: config.display_url,
auth: {
- type: config.auth.type === 'ssh' ? 'ssh' : 'https',
+ type: config.auth.type,
privkey: config.auth.privkey,
pubkey: config.auth.pubkey,
username: config.auth.username,
@@ -21,7 +21,7 @@ module.exports = {
url: String,
display_url: String,
auth: {
- type: { type: String, enum: ['ssh', 'https'] },
+ type: { type: String, enum: ['ssh', 'https', 'http'] },
privkey: String,
pubkey: String,
username: String,
View
@@ -19,8 +19,8 @@ function safespawn() {
return c
}
-function httpsCloneCmd(config, branch) {
- var urls = utils.httpsUrl(config)
+function httpCloneCmd(config, branch) {
+ var urls = utils.httpUrl(config)
, screen = 'git clone --recursive ' + urls[1] + ' .'
, args = ['clone', '--recursive', urls[0], '.']
if (branch) {
@@ -73,7 +73,7 @@ function clone(dest, config, ref, context, done) {
return utils.gitaneCmd(cmd, dest, config.auth.privkey, context, done)
}
context.cmd({
- cmd: httpsCloneCmd(config),
+ cmd: httpCloneCmd(config),
cwd: dest
}, done)
}

0 comments on commit 4c56e6d

Please sign in to comment.