-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fix regex for public bitbucket repo #3533
Fix regex for public bitbucket repo #3533
Conversation
I'm not sure that manually writing and adding these tests is the best way to do this. The git protocol is very complex. Is there an external library we can use? For instance, https://github.com/npm/hosted-git-info would work if we were in JavaScript land. https://github.com/npm/hosted-git-info/blob/master/index.js#L44 is an example of a regex we could borrow to bootstrap making a library if there isn't one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Agree. Although, most of the code is writting by hand so, following this pattern here is enough. On the other hand, as you said, we will want to achieve this by relying in a external library. We have talked about using gitpython: https://gitpython.readthedocs.io/en/stable/intro.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
GitPython is for interacting with git itself (inspecting a repo, performing a branch, etc.). What we are looking for is a library that parses and assembles GitHub/Bitbucket/etc. I'm not aware of a library like that in Python. It's very possible that the code we have is the best start of such a library.
Might be worth just making a port of hosted-git-info, then. |
We started to use gitpython on a different branch, though I'm not sure if it has helpers to determine valid repo names. Perhaps this pushes us to use pygit2 or dulwich instead. I could see importing |
I didn't check dulwich, but pygit2 seems to be too complex to install properly and I didn't like the API when I checked it yesterday. GitPython was very clean and direct to understand. dulwich seems to be similar than GitPython. |
Mmm... I wouldn't be too sure. We need to validate web service URLs (github.com, gitlab.com and bitbucket.com) not valid git URLs --that's another story. Mercurial allows you to just run:
|
We need exactly what @RichardLitt mentioned, https://github.com/npm/hosted-git-info The templates used to build the regex, https://github.com/npm/hosted-git-info/blob/latest/git-host-info.js#L3-L49 |
Ah true, we're looking to classify the provider here as well. We could copy the following regex patterns in from: It might be a helpful port to python though, bonus points to anyone that wants to maintain that :) I'd say this is all a new ticket though. This looks okay to merge now. |
I just realized that on #3501 I forgot to test a bitbucket repo as a logout user.
When you are login, the clone url is
But when you are log out look like this
This ends with
.git
Sorry for the bug :(