fix scm detection for specific git urls

pull/51/merge
Fabian Jakobs 2015-04-02 08:40:49 +00:00
rodzic 4909adf379
commit cb368e4ab9
2 zmienionych plików z 28 dodań i 4 usunięć

22
node_modules/c9/scm_url_parse.js wygenerowano vendored
Wyświetl plik

@ -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;
}
}; };
}); });

10
node_modules/c9/scm_url_parse_test.js wygenerowano vendored
Wyświetl plik

@ -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();
});
}); });
}); });