From 822bff4e108bd684ce2bd2c079b61c9a92ca0768 Mon Sep 17 00:00:00 2001 From: basdewachter Date: Fri, 29 Apr 2016 15:31:05 +0200 Subject: [PATCH] add support for gitlab scm urls --- node_modules/c9/scm_url_parse.js | 4 ++ node_modules/c9/scm_url_parse_test.js | 99 +++++++++++++++++---------- 2 files changed, 65 insertions(+), 38 deletions(-) diff --git a/node_modules/c9/scm_url_parse.js b/node_modules/c9/scm_url_parse.js index 174e6c66..ced57767 100644 --- a/node_modules/c9/scm_url_parse.js +++ b/node_modules/c9/scm_url_parse.js @@ -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"; } diff --git a/node_modules/c9/scm_url_parse_test.js b/node_modules/c9/scm_url_parse_test.js index 726b0144..62c16561 100644 --- a/node_modules/c9/scm_url_parse_test.js +++ b/node_modules/c9/scm_url_parse_test.js @@ -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",