src-d / go-git

Project has been moved to: https://github.com/go-git/go-git
https://github.com/go-git/go-git
Apache License 2.0
4.91k stars 541 forks source link

Add numeric username support for SSH urls. #1214

Closed 117 closed 5 years ago

117 commented 5 years ago

In my attempt to use SSH I discovered my username was being matched as the port ... this PR modifies the regex to allow for numeric usernames.

git@github.com:117/myrepo // 117 was being matched as the port 

This new expression matches the following even when the username in the path is numerical.

git@github.com:james/example // user: git, host: github.com, path: james/example
git@github.com:007/example // user: git, host: github.com, path: 007/example
git@github.com:22:007/example // user: git, host: github.com, port: 22, path: 007/example
git@github.com:22:james/example // user: git, host: github.com, port: 22, path: james/example

I tried to leave as much of the old expression as possible.

Signed-off-by: Chief admin@117.sh

mcuadros commented 5 years ago

Can you provide some tests?

117 commented 5 years ago

Okay I have added tests.

mcuadros commented 5 years ago

Sorry but we use gocheck for the test :/

117 commented 5 years ago

Ah, okay changed the test to use gocheck format.