kopia lustrzana https://github.com/c9/core
fix scm detection for specific git urls
rodzic
4909adf379
commit
cb368e4ab9
|
@ -31,17 +31,31 @@ define(function(require, exports, module) {
|
||||||
parsed.hostname &&
|
parsed.hostname &&
|
||||||
parsed.slashes &&
|
parsed.slashes &&
|
||||||
parsed.pathname
|
parsed.pathname
|
||||||
)
|
) {
|
||||||
|
var scm;
|
||||||
|
var provider = providers[parsed.hostname] || defaultProvider;
|
||||||
|
switch (provider) {
|
||||||
|
case "github":
|
||||||
|
scm = "git";
|
||||||
|
break;
|
||||||
|
case "bitbucket":
|
||||||
|
scm = parsed.pathname.match(/\.git$/) ? "git": "hg";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
scm = parsed.pathname.match(/\.git$/) ? "git": "hg";
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
protocol: parsed.protocol,
|
protocol: parsed.protocol,
|
||||||
scm: parsed.pathname.match(/\.git$/) ? "git": "hg",
|
scm: scm,
|
||||||
provider: providers[parsed.hostname] || defaultProvider,
|
provider: provider,
|
||||||
auth: parsed.auth || "",
|
auth: parsed.auth || "",
|
||||||
hostname: parsed.hostname,
|
hostname: parsed.hostname,
|
||||||
pathname: parsed.pathname.replace(/^\/+/, ""),
|
pathname: parsed.pathname.replace(/^\/+/, ""),
|
||||||
full: url
|
full: url
|
||||||
};
|
};
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
|
@ -64,6 +64,16 @@ describe(__filename, function(){
|
||||||
assert.equal(url.pathname, "fjakobs/juhu");
|
assert.equal(url.pathname, "fjakobs/juhu");
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should parse github URL without .git", function(done) {
|
||||||
|
var url = parse("https://github.com/arunoda/meteor-streams");
|
||||||
|
assert.equal(url.protocol, "https:");
|
||||||
|
assert.equal(url.scm, "git");
|
||||||
|
assert.equal(url.provider, "github");
|
||||||
|
assert.equal(url.hostname, "github.com");
|
||||||
|
assert.equal(url.pathname, "arunoda/meteor-streams");
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
Ładowanie…
Reference in New Issue