kopia lustrzana https://github.com/c9/core
Merge pull request +13708 from c9/profile-gitlab-urls
Support for gitlab scm urlspull/299/head
commit
612efaf886
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
Ładowanie…
Reference in New Issue