1803: post-review : git http or https remote with username name in remote url.

benbe*****@gmai***** (Google Code) (Is this you? Claim this profile.)
chipx86
chipx86
Feb. 7, 2011
1572
What version are you running?
RBTools 0.2


What's the URL of the page containing the problem?
NA

What steps will reproduce the problem?
1.Clone a http or https repo using git with a username in the repo url
2.Git repo on the reviewboard server lacks username in field.
3.post-review doesn't strip username from url
4.post-review gives error 
The repository path "https://my.username@myserver.name.com/path/to/projectrepo.git" is not in the list of known repositories on the server.

What is the expected output? What do you see instead?
Needs to strip username from the url field.
#1 benbe*****@gmai***** (Google Code) (Is this you? Claim this profile.)
Patch to fix the problem.
Only does username, not password. 
  • +
    commit e810e17ddb0c21acd52ad60c5bdc1e507b03f4ea
    Author: benjamin <benbennett@gmail.com>
    Date:   Wed Sep 8 11:16:08 2010 -0500
        git http or https remote with username name in remote url.
        issue 1803
        http://code.google.com/p/reviewboard/issues/detail?id=1803
    diff --git a/rbtools/postreview.py b/rbtools/postreview.py
    index 5bd1f64..01ab404 100755
    --- a/rbtools/postreview.py
    +++ b/rbtools/postreview.py
    @@ -2287,6 +2287,12 @@ class GitClient(SCMClient):
             upstream_remote = upstream_branch.split('/')[0]
             origin_url = execute(["git", "config", "remote.%s.url" % upstream_remote],
                              ignore_errors=ignore_errors)
    +        origin_url = origin_url.rstrip('\n')
    +        if(origin_url.startswith('http')):
    +            parse_result= urlparse(origin_url)
    +            debug("http url : "+origin_url) 
    +            origin_url=parse_result.geturl().replace(parse_result.username+'@','',1)
    +            debug("modified http url : "+origin_url) 
     
             ret
#2 benbe*****@gmai***** (Google Code) (Is this you? Claim this profile.)
fix of the fix 
  • +
    commit 18022f894f5af2d98935369573ace8eb40268b49
    Author: benjamin <benbennett@gmail.com>
    Date:   Wed Sep 8 12:08:30 2010 -0500
        git http or https remote with username name in remote url.
        issue 1803
        http://code.google.com/p/reviewboard/issues/detail?id=1803
    diff --git a/rbtools/postreview.py b/rbtools/postreview.py
    index 5bd1f64..a774c4b 100755
    --- a/rbtools/postreview.py
    +++ b/rbtools/postreview.py
    @@ -2287,7 +2287,13 @@ class GitClient(SCMClient):
             upstream_remote = upstream_branch.split('/')[0]
             origin_url = execute(["git", "config", "remote.%s.url" % upstream_remote],
                              ignore_errors=ignore_errors)
    -
    +        origin_url = origin_url.rstrip('\n')
    +        if(origin_url.startswith('http')):
    +            parse_result= urlparse(origin_url)
    +            debug("http url : "+origin_url) 
    +            if(parse_result.username):
    +                origin_url=parse_result.geturl().replace(parse_result.username+'@','',1)
    +            debug("mod
chipx86
#3 chipx86
Hi Ben,

Can you put this up on http://reviews.reviewboard.org/? All patches should go there to be reviewed. Thanks!
  • +Confirmed
  • +Component-RBTools
#4 benbe*****@gmai***** (Google Code) (Is this you? Claim this profile.)
Sure here you go 
http://reviews.reviewboard.org/r/1771/  

Made a few slight changes to such to correct whitespace and repetitive code.   
#5 benbe*****@gmai***** (Google Code) (Is this you? Claim this profile.)
Still working on this , I went ahead and fixed it for ssh,ftp,ftps,https,http.

I will be uploading a new diff in a bit.

There should be an option to set reviewboard repo url, since there are multiple ways to access the same repo.
In are env you can access it via https,ssh, and reviewboard accesses it via file://
but that would be an enhancement and another ticket, so I am going to have a remove_username method , I have written a rather extensive test case using the git clone manual , and did all the ones that might have username Except scp
#7 henr*****@gmai***** (Google Code) (Is this you? Claim this profile.)
The latest attached patch from http://reviews.reviewboard.org/r/1771/diff/ solved my issues. with the latest postreview.py code from the rbtools github repository. it would be great if this patch went into the next version of rbtools.
chipx86
#8 chipx86
The upcoming RBTools 0.3.1 release (especially combined with the upcoming Review Board 1.5.3) fixes this by allowing .reviewboardrc to specify a REPOSITORY= field, which can be an ID, a path, or (if using 1.5.3) the actual displayed name of the repository.
  • -Confirmed
    +Fixed
  • +chipx86