rscherf / GitLink

Open your Sublime Text files on GitHub, Bitbucket, Gitlab or Codebase
http://ryan.sc
35 stars 25 forks source link

Fix git:// repositories #7

Closed akrabat closed 8 years ago

akrabat commented 8 years ago

This PR fixes #6.

Remote git repositories can be of the form https://domain/user/repo or git@domain:user/repo, so update the regular expression to look for either type. I created https://regex101.com/r/pZ3tN3/2 & https://regex101.com/r/iS5tQ4/2 to work this out.

I've also updated the logic to extract details from the git_config parameter as the information is in different places based on the type of git repository.

The format for non-codebasehq repositories is: SSH: {example.com}:{user}/{repo}.git HTTP: {example.com}/{user}/{repo}.git

The codebasehq format is slightly different as we need the project and the user name is in a different place: SSH: codebasehq.com:{user}/{project}/{repo}.git HTTP: {user}.codebasehq.com/{project}/{repo}.git

Finally I swapped the if test for codebasehq to a positive check to make it easier to read.

rscherf commented 8 years ago

Thanks for looking into this. Agreed, your solution is much better. I've sort of let the project go and haven't been using the plugin much, so I never noticed.