hyper123 / git-repo

Automatically exported from code.google.com/p/git-repo
Apache License 2.0
0 stars 0 forks source link

resolve fetch url even though it's not relative one. #94

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Affected Version:1.13
Environment:ubuntu10.10

What steps will reproduce the problem?

I have gitolite hosted fetch address in manifest.xml like this:

  <remote  name="github"
           fetch="git@git.mysite.net:mirror/github" />

repo join it after manifest url even thoung it's not relative one.
and sync failed.

It's happen at _resoveFetchUrl() of manifest_xml.py

What is the expected output? What do you see instead?

If the fetch url is not relative one (not starts with '.'),
shouldn't try join it with manifest's url.

Please provide any additional information below.

Attached my patch for fix this problem.

Original issue reported on code.google.com by ff4...@gmail.com on 2 Nov 2011 at 8:10

Attachments:

GoogleCodeExporter commented 9 years ago
Relative urls often don't have to start with a '.', so this won't work.

urljoin will already use the second parameter url if it is not relative.  What 
exactly does the function end up returning in your example?

Original comment by conl...@google.com on 2 Nov 2011 at 4:45

GoogleCodeExporter commented 9 years ago
for example,

    urlparse.urljoin("http://manifest-url.net/manifest.git", \
        "git@ssh.my-gitolite.net:some/project")

returns;

    'http://manifest-url.net/git@ssh.my-gitolite.net:some/project'

It should be;

    'git@ssh.my-gitolite.net:some/project'

I did it with Python 2.6.6  in Ubuntu10.10.

Original comment by ff4...@gmail.com on 3 Nov 2011 at 2:25

GoogleCodeExporter commented 9 years ago
it's not bug from the urlparse.
I found following description in http://docs.python.org/library/urlparse.html

> Following the syntax specifications in RFC 1808, urlparse recognizes a netloc 
only if it is properly introduced by ‘//’. Otherwise the input is presumed 
to be a relative URL and thus to start with a path component.

How about check the url with '@'?
new patch attached.

Original comment by ff4...@gmail.com on 3 Nov 2011 at 3:21

Attachments:

GoogleCodeExporter commented 9 years ago
Seems a bit aggressive.  Could you change this so that this only gets triggered 
when the first '@' comes before the first '/'?

Also, while you are at it, could you change the comment to something like:
# Prevent urljoin from misinterpreting urls with a username
# as relative (ex: git@example.com:port/project)

Original comment by cco3@android.com on 4 Nov 2011 at 5:18

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I concerned about ssh address which not contains '/' like this:

    git@example.com:port

But, I think checking the url with '@' and ':' is good enough.
Patch attached.

Original comment by ff4...@gmail.com on 5 Nov 2011 at 5:20

Attachments:

GoogleCodeExporter commented 9 years ago
I'm pretty sure that both @ and : are valid url characters after the host and 
port.  

What I'm asking for is something like re.match(r'[^/]+@', url)

Original comment by cco3@android.com on 7 Nov 2011 at 5:10

GoogleCodeExporter commented 9 years ago
Thanks for keep responding.

In that case, even "git@example.com:port" can be a relative url.
and, can't judge with silly regex magic.

So, I think a new attibute -something like "abs_fetch"- needed in
remote node of the xml to avoid ambiguity. for example:

    <remote  name="my_github"  abs_fetch="git@github.com:suapapa" />

I can work for it if you agree with it.
Please give me some advice.

Original comment by ff4...@gmail.com on 8 Nov 2011 at 12:08

GoogleCodeExporter commented 9 years ago
If you want to avoid ambiguity, I think it would be best to simply specify the 
scheme (ie ssh://) in the url.  Do you have any problems if you do that?

Original comment by cco3@android.com on 9 Nov 2011 at 6:58

GoogleCodeExporter commented 9 years ago
As we discussed here, current repo handle URL as a relative one
if it don't have protocol header (ie ssh://).

    git@example.com:path/to/projetct.git

It's a scp-like syntax. (check 'GIT URLS' in `git help clone`)
Oh! I forgot mention it. In scp syntax use ':' for path not port.

and can't attach 'ssh://' in front of the URL
(becasue of in ssh:// they use ':' for port)

following is part of `git help clone`:

    GIT URLS
    ...
         An alternative scp-like syntax may also be used with the ssh protocol:
           ·   [user@]host.xz:path/to/repo.git/

And, It's very common.
Many git host use this scp-like syntax.
Even the GitHub use this URL in private clone address.

I think protocol header mandatory policy in current repo is too restrict.

Original comment by ff4...@gmail.com on 10 Nov 2011 at 1:21

GoogleCodeExporter commented 9 years ago
You can't do "ssh://git@git.mysite.net/mirror/github"?

Original comment by cco3@android.com on 11 Nov 2011 at 10:12

GoogleCodeExporter commented 9 years ago
It works! 
With some fix in my manifest.xml like this;

    ssh://git@git.mysite.net/mirror/github

everything works fine now.

What I tried before is:

   ssh://git@git.mysite.net:mirror/github

Thanks for the help and patient.

Original comment by ff4...@gmail.com on 14 Nov 2011 at 6:28

GoogleCodeExporter commented 9 years ago
No problem!

Original comment by cco3@android.com on 14 Nov 2011 at 7:26

GoogleCodeExporter commented 9 years ago

Original comment by david.pu...@sonymobile.com on 9 Apr 2013 at 1:23