+
Skip to content

Fix git-blame error on url missing .git #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 29, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/util/RemoteRevision.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 25 additions & 1 deletion spec/RemoteRevision-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -90,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;
Expand All @@ -116,4 +140,4 @@ describe('RemoteRevision', function() {

});

});
});
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载