From 0749dc8c0b7f8520dc750f2cf526d39f8d51a4ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Sch=C3=BC=C3=9Fler?= Date: Thu, 29 May 2014 20:28:42 +0200 Subject: [PATCH 1/3] :bug: Fix git-blame error on url missing .git --- lib/util/RemoteRevision.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/RemoteRevision.js b/lib/util/RemoteRevision.js index e6895a1..bea136a 100644 --- a/lib/util/RemoteRevision.js +++ b/lib/util/RemoteRevision.js @@ -61,7 +61,7 @@ _.extend(RemoteRevision.prototype, { }, parseProjectAndRepo: function() { - var pattern = /[\:\/]([\w-]*)\/([\w-]*)\.git$/; + var pattern = /[\:\/]([\w-]*)\/([\w-]*)(\.git)?$/; var matches = this.remote.match(pattern); // if we have no matches just return empty object. caller should validate From b4e60fe1e70651ba3b5e86306841d8dbc7944fca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Sch=C3=BC=C3=9Fler?= Date: Thu, 29 May 2014 21:51:58 +0200 Subject: [PATCH 2/3] Add spec for repo url without .git ending --- spec/RemoteRevision-spec.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/spec/RemoteRevision-spec.js b/spec/RemoteRevision-spec.js index dc6cb5f..cc3e4f7 100644 --- a/spec/RemoteRevision-spec.js +++ b/spec/RemoteRevision-spec.js @@ -66,6 +66,18 @@ describe('RemoteRevision', function() { }); }); + it('Should parse a standard github url without the .git ending correctly', function () { + var githubRemote = 'git@github.com:project/someRepo'; + instance.remote = githubRemote; + + var output = instance.parseProjectAndRepo(); + + expect(output).toEqual({ + project: 'project', + repo: 'someRepo' + }); + }); + it('Should parse a read only github url correctly', function () { var githubHttpRemote = 'https://github.com/project/someRepo.git'; instance.remote = githubHttpRemote; @@ -116,4 +128,4 @@ describe('RemoteRevision', function() { }); -}); \ No newline at end of file +}); From c12d40f8f97dc04d42f508e72f5dfa9d4f4eb5d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Sch=C3=BC=C3=9Fler?= Date: Thu, 29 May 2014 22:02:43 +0200 Subject: [PATCH 3/3] Add spec repo url with dashes and without .git ending --- spec/RemoteRevision-spec.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/RemoteRevision-spec.js b/spec/RemoteRevision-spec.js index cc3e4f7..6b48701 100644 --- a/spec/RemoteRevision-spec.js +++ b/spec/RemoteRevision-spec.js @@ -102,6 +102,18 @@ describe('RemoteRevision', function() { }); }); + it('Should parse a repo url with dashes and wthout a .git ending correctly', function () { + var githubHttpRemote = 'https://github.com/some-project/some-repo'; + instance.remote = githubHttpRemote; + + var output = instance.parseProjectAndRepo(); + + expect(output).toEqual({ + project: 'some-project', + repo: 'some-repo' + }); + }); + it('Should work with a url with a port', function() { var portRemoteUrl = 'ssh://git@git.my-company.com:2222/group/repo-name.git'; instance.remote = portRemoteUrl;