nephila / giturlparse

Parse & rewrite git urls (supports GitHub, Bitbucket, Assembla ...)
https://pypi.python.org/pypi/giturlparse
Apache License 2.0
31 stars 21 forks source link

Support parsing SSH URLs with random domains #47

Closed JBrVJxsc closed 1 year ago

JBrVJxsc commented 1 year ago

Description

Currently, the library does not support parsing SSH URLs with random domains, e.g., git@github.com-work:nephila/giturlparse.git.

Use cases

When we git clone git@github.com:nephila/giturlparse.git, what happens under the hood is that git will invoke ssh, which takes git as SSH username and github.com as the host; however, there are cases where people need different alias names for github.com, e.g., when they have multiple ssh keys locally, what they often do is to add multiple host configs, e.g., github.com-personal and github.com-work in ~/.ssh/config, and then use that alias to pull and push, that way the ssh will automatically know which SSH key to use.

Proposed solution

Add regular expression support for random domains.

Alternatives

None I could think of.

Additional information

yakky commented 1 year ago

We can trick the parser to match it, but I cannot think how we can match this with the github parser, because for github we match the profile.

As of current master I could parse it with the gitlab parser, which should cover most of the use cases, but it report the platform as "gitlab" in the returning object

yakky commented 1 year ago

I added a test case for your URL to ensure against future regresions

yakky commented 1 year ago

Fixed by #52