tjtelan / git-url-parse-rs

Parser of git repo urls for Rust
MIT License
15 stars 8 forks source link

[Merged by Bors] - Support Gerrit source code #24

Closed kaplanelad closed 2 years ago

kaplanelad commented 2 years ago

Hey, In Gerrit source code there is no organization in the remote URL

Gerrit repo remote origin URL:

git config --get remote.origin.url`
ssh://f589726c3611:29418/test-repo

in this case, when trying to parse the remote URL I get the error: git url is not of expected format.

How to test it:

  1. run Gerrit docker image:
    docker run -ti -p 8080:8080 -p 29418:29418 gerritcodereview/gerrit
  2. Create a repository
  3. clone the repository
  4. Run GitUrl::parse on the git remote URL
  5. you should get an error, although the remote URL is valid in this case

Fix

If the Git URL is not strat with ssh, keep the existing code behavior if the code starts with ssh I'm taking the position like you have today from splitpath

added a test case to check this scenario, and all the existing test is pass successfully

tjtelan commented 2 years ago

@kaplanelad thanks for the contribution!

I am noticing an increase of working around the organization identification from the URL. My initial approach was not well thought out, and that's my bad.

Ideally you should not need to be so mindful about adding ssh:// for parse to work as expected. I have https://github.com/tjtelan/git-url-parse-rs/issues/10 tracking this future behavior change.

That being said, I think this looks good enough to solve your use-case. I'll publish this crate update soon. Thanks again!

tjtelan commented 2 years ago

bors r+

bors[bot] commented 2 years ago

Pull request successfully merged into main.

Build succeeded:

kaplanelad commented 2 years ago

Thanks @tjtelan