Merge pull request +13708 from c9/profile-gitlab-urls

Support for gitlab scm urls
pull/299/head
Matthijs van Henten 2016-05-02 11:50:52 +02:00
commit 612efaf886
2 zmienionych plików z 65 dodań i 38 usunięć

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

@ -13,6 +13,7 @@ define(function(require, exports, module) {
"bitbucket.org": "bitbucket",
"github.com": "github",
"source.developers.google.com": "google",
"gitlab.com": "gitlab",
};
var defaultProvider = "unknown";
@ -75,6 +76,9 @@ define(function(require, exports, module) {
case "bitbucket":
scm = parsed.pathname.match(/\.git$/) ? "git": "hg";
break;
case "gitlab":
scm = "git";
break;
default:
scm = parsed.pathname.match(/\.git$/) ? "git": "hg";
}

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

@ -16,57 +16,60 @@ describe(__filename, function() {
describe("#parse", function() {
it("should parse ssh url", function(done) {
var url = parse("git@github.com:fjakobs/lispjs.git");
assert.equal(url.scm, "git");
assert.equal(url.protocol, "ssh:");
assert.equal(url.auth, "git");
assert.equal(url.hostname, "github.com");
assert.equal(url.pathname, "fjakobs/lispjs.git");
done();
var url = parse("git@github.com:fjakobs/lispjs.git");
assert.equal(url.scm, "git");
assert.equal(url.protocol, "ssh:");
assert.equal(url.provider, "github");
assert.equal(url.auth, "git");
assert.equal(url.hostname, "github.com");
assert.equal(url.pathname, "fjakobs/lispjs.git");
done();
}),
}),
it("should parse git url", function(done) {
var url = parse("git://github.com/fjakobs/lispjs.git");
assert.equal(url.scm, "git");
assert.equal(url.protocol, "git:");
assert.equal(url.provider, "github");
assert.equal(url.hostname, "github.com");
assert.equal(url.pathname, "fjakobs/lispjs.git");
done();
}),
it("should parse git url", function(done) {
var url = parse("git://github.com/fjakobs/lispjs.git");
assert.equal(url.scm, "git");
assert.equal(url.protocol, "git:");
assert.equal(url.hostname, "github.com");
assert.equal(url.pathname, "fjakobs/lispjs.git");
done();
it("should parse https url", function(done) {
var url = parse("https://fjakobs@github.com/fjakobs/lispjs.git");
assert.equal(url.protocol, "https:");
assert.equal(url.scm, "git");
assert.equal(url.auth, "fjakobs");
assert.equal(url.provider, "github");
assert.equal(url.hostname, "github.com");
assert.equal(url.pathname, "fjakobs/lispjs.git");
done();
}),
}),
it("should parse https url", function(done) {
var url = parse("https://fjakobs@github.com/fjakobs/lispjs.git");
assert.equal(url.protocol, "https:");
assert.equal(url.scm, "git");
assert.equal(url.auth, "fjakobs");
assert.equal(url.hostname, "github.com");
assert.equal(url.pathname, "fjakobs/lispjs.git");
done();
}),
it("should parse Bitbucket url", function(done) {
var url = parse("git@bitbucket.org/Richard/expressling.git");
assert.equal(url.protocol, "ssh:");
assert.equal(url.scm, "git");
assert.equal(url.auth, "git");
assert.equal(url.hostname, "bitbucket.org");
assert.equal(url.pathname, "Richard/expressling.git");
done();
});
it("should parse Bitbucket url", function(done) {
var url = parse("git@bitbucket.org/Richard/expressling.git");
assert.equal(url.protocol, "ssh:");
assert.equal(url.scm, "git");
assert.equal(url.auth, "git");
assert.equal(url.provider, "bitbucket");
assert.equal(url.hostname, "bitbucket.org");
assert.equal(url.pathname, "Richard/expressling.git");
done();
});
it("should parse Bitbucket hg ssh url", function(done) {
var url = parse("ssh://hg@bitbucket.org/fjakobs/juhu");
assert.equal(url.protocol, "ssh:");
assert.equal(url.scm, "hg");
assert.equal(url.provider, "bitbucket");
assert.equal(url.hostname, "bitbucket.org");
assert.equal(url.pathname, "fjakobs/juhu");
done();
});
it("should parse github URL without .git", function(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");
@ -76,7 +79,27 @@ describe(__filename, function() {
done();
});
it("Should refuse a git url with dangerous shell chars in it", function() {
it("should parse Gitlab url", function(done) {
var url = parse("git@gitlab.com:bdewachter/testfiles.git");
assert.equal(url.scm, "git");
assert.equal(url.protocol, "ssh:");
assert.equal(url.provider, "gitlab");
assert.equal(url.hostname, "gitlab.com");
assert.equal(url.pathname, "bdewachter/testfiles.git");
done();
}),
it("should parse Gitlab url without .git", function(done) {
var url = parse("https://gitlab.com/bdewachter/testfiles.git");
assert.equal(url.protocol, "https:");
assert.equal(url.scm, "git");
assert.equal(url.provider, "gitlab");
assert.equal(url.hostname, "gitlab.com");
assert.equal(url.pathname, "bdewachter/testfiles.git");
done();
});
it("should refuse a git url with dangerous shell chars in it", function() {
var validUrls = [
"https://github.com/arunoda/meteor-streams",
"https://fjakobs@github.com/fjakobs/lispjs.git",