Skip to content
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

urlparse doesn't always give 'base url' #31

Open
tverlaan opened this issue Feb 4, 2015 · 8 comments
Open

urlparse doesn't always give 'base url' #31

tverlaan opened this issue Feb 4, 2015 · 8 comments
Assignees
Labels

Comments

@tverlaan
Copy link

tverlaan commented Feb 4, 2015

In quite a few cases with my own repositories git-passport doesn't recognize the url correctly. This has to do with the use of urlparse. Some examples:

>>> from urllib.parse import urlparse

>>> urlparse('git@github.com:tverlaan/git-passport')
ParseResult(scheme='', netloc='', path='git@github.com:tverlaan/git-passport', params='', query='', fragment='')

>>> urlparse('github.com:tverlaan/git-passport')
ParseResult(scheme='github.com', netloc='', path='tverlaan/git-passport', params='', query='', fragment='')

>>> urlparse('https://github.com/tverlaan/git-passport.git')
ParseResult(scheme='https', netloc='github.com', path='/tverlaan/git-passport.git', params='', query='', fragment='')

I can think of two alternatives for fixing this issue:

  • string match between url in passport and git config url
  • improve url parsing

The first solution would also allow for automatic matching different usernames for different projects with the same base url (say github.com). I'm happy to issue a PR, but I wanted to discuss first.

@frace
Copy link
Owner

frace commented Feb 4, 2015

@tverlaan Thank you for your report!
I could imagine the easiest solution would be to do a simple string match like

if "github.com" in "git@github.com:tverlaan/git-passport":
    ...

I'm not quite sure if it'd be more elegant to find a solution by using urllib? Because it is related in a way would you like to have a look at this issue: #28? I could incorporate the changes right in that branch.

@frace frace added the bug label Feb 4, 2015
@frace frace self-assigned this Feb 4, 2015
@tverlaan
Copy link
Author

tverlaan commented Feb 4, 2015

That would be indeed the most simple solution. This would also make it possible to have different name/email for github.com:tverlaan and github.com:somethingelse.

@tverlaan
Copy link
Author

tverlaan commented Feb 4, 2015

I've thought about it. I think pattern matching is the way to go. It will cover more usecases but still allow for string matching.

@frace
Copy link
Owner

frace commented Feb 4, 2015

@tverlaan Could you please give an example?

@tverlaan
Copy link
Author

tverlaan commented Feb 8, 2015

Well, some domains have multiple TLDs. Instead of listing each TLD (with name and possibly something after the slash, like my name), I want to use a regular expression. Eg.

>>> example = re.match('https://github\.(com|org)/tverlaan','https://github.org/tverlaan')
>>> example.group(0)
'https://github.org/tverlaan'
>>> example = re.match('https://github\.(com|org)/tverlaan','https://github.com/tverlaan')
>>> example.group(0)
'https://github.com/tverlaan'
>>> example = re.match('https://github\.(com|org)/tverlaan','https://github.net/tverlaan')
>>> example.group(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'group'
>>> 

It's maybe not the best example, but you can imagine there are a lot more uses for this.

@frace
Copy link
Owner

frace commented Feb 8, 2015

Ok, I see.

@dhergert
Copy link

dhergert commented Aug 1, 2016

@frace - I see no pull requests have been approved in 18 months. If we submit a PR, can you review and incorporate?

@Richard-Degenne
Copy link

Allow me to bump this up.

Not being able to make the most out of git-passport when using ssh is a bit sad, it'd be lovely to have it merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants