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

URL Parsing Failure Issue #193

Closed
linrongbin16 opened this issue Jan 5, 2024 · 4 comments · Fixed by #195
Closed

URL Parsing Failure Issue #193

linrongbin16 opened this issue Jan 5, 2024 · 4 comments · Fixed by #195

Comments

@linrongbin16
Copy link
Owner

linrongbin16 commented Jan 5, 2024

There are many people had the internal url parsing exception, which is because of missing use cases.

Please add your use cases here.

Three things are needed:

  1. The output of git remote get-url origin.
  2. The expected git host url example.
  3. The router config you will use to make it work.
@linrongbin16 linrongbin16 pinned this issue Jan 5, 2024
@linrongbin16 linrongbin16 changed the title Please add your use cases URL Parsing Failure Issue Jan 5, 2024
@linrongbin16
Copy link
Owner Author

linrongbin16 commented Jan 5, 2024

http/https protocol

case-1 https://github.com/linrongbin16/gitlinker.nvim

  1. git remote url config output: https://github.com/linrongbin16/gitlinker.nvim.git
  2. expected git host url: https://github.com/linrongbin16/gitlinker.nvim/blob/c5a4bdd78f3dab3c6017a3b56932b334b94f55c6/.github/ISSUE_TEMPLATE/bug.md?plain=1#L10
  3. router configuration: default config

case-2 https://git.samba.org/samba.git and https://git.samba.org/bbaumbach/samba.git

relate ticket: #146

  1. git remote url output: https://git.samba.org/samba.git and https://git.samba.org/bbaumbach/samba.git
  2. expected git host url: https://git.samba.org/?p=samba.git;a=blob;f=wscript;hb=83e8971c0f1c1db8c3574f83107190ac1ac23db0#l7 and https://git.samba.org/?p=bbaumbach/samba.git;a=blob;f=wscript;hb=8de348e9d025d336a7985a9025fe08b7096c0394#l7
  3. router configuration: default config

git@/ssh protocol

case-2 [email protected]:linrongbin16/gitlinker.nvim.git

  1. git remote url config output: [email protected]:linrongbin16/gitlinker.nvim.git
  2. expected git host url: https://github.com/linrongbin16/gitlinker.nvim/blob/c5a4bdd78f3dab3c6017a3b56932b334b94f55c6/.github/ISSUE_TEMPLATE/bug.md?plain=1#L10
  3. router configuration: default config

case-3 ssh resolved host name

related ticket: #87

  1. git remote url config output: [email protected]:linrongbin16/gitlinker.nvim.git
  2. expected git host url: https://github.com/linrongbin16/gitlinker.nvim/blob/c5a4bdd78f3dab3c6017a3b56932b334b94f55c6/.github/ISSUE_TEMPLATE/bug.md?plain=1#L10
  3. router configuration: default config

user have configured host name mapping in ~/.ssh/config, for example:

Host github-personal.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_personal
    Compression no

Then ssh -ttG will output something contains below line:

hostname github.com

Thus resolved host name is github.com (instead of github-personal.com).

case-4 ssh://[email protected]/org/repo.git

relate ticket: #114

  1. git remote url config output: (not sure I guess it's) [email protected]/org/repo.git or ssh://[email protected]/org/repo.git (hi @skoch13 could you help confirm?)
  2. expected git host url: https://xyz.abc/org/repo/repositories/c5a4bdd78f3dab3c6017a3b56932b334b94f55c6/files?line=1
  3. router configuration: [git%.xyz%.abc] = 'https://xyz.abc/{_A.USER}/{_A.REPO}/repositories/{_A.REV}/{_A.FILE}?line={_A.LSTART}'

case-5 ssh://[email protected]/org/repo.git

relate ticket: #187

  1. git remote url config output: (not sure I guess it's) [email protected]/org/repo.git or ssh://[email protected]/org/repo.git
  2. expected git host url: (I guess it's) https://[email protected]/org/repo/c5a4bdd78f3dab3c6017a3b56932b334b94f55c6/files#L14
  3. router configuration: (I guess it's) [username%.github%.com] = 'https://[email protected]/{_A.USER}/{_A.REPO}/{_A.REV}/{_A.FILE}#{_A.LSTART}'

case-6 ssh://[email protected]/repo.git

see: https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols#:~:text=on%20your%20system.-,The%20SSH%20Protocol,to%20set%20up%20and%20use.

  1. git remote url config output: ?
  2. expected git host url: ?

@linrongbin16
Copy link
Owner Author

linrongbin16 commented Jan 6, 2024

I found several things:

  1. https://www.gnu.org/software/emacs/manual/html_node/url/Parsed-URIs.html
  2. https://github.com/IonicaBizau/git-url-parse
  3. https://stackoverflow.com/questions/31801271/what-are-the-supported-git-url-formats
  4. https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols

The 3nd link contains many use cases, I will refactor the url parser, and try to cover them.


Git url parsing design

Syntax:

  1. use {} contains the component keywords of git url (they're also the same thing in the README.md - Fully Customize Urls section).
  2. use [] contains optional (0 or 1) components.
  3. use []* contains 0 or more components.
  4. use []+ contains 1 or more components.

Url patterns:

  1. {protocol}://[{username}[:{password}]@]{host}[/{org}]*/{repo}
  2. [{username}[:{password}]@]{host}:[{org}/]*{repo}
  3. [file://]/[{org}/]*{repo}

This pattern could cover below cases:

  • {protocol}://{host}/[{org}/]{repo}, example:
    • https://github.com/org/repo.git
    • ssh://github.com/org/repo.git
    • https://git.samba.com/samba.git
  • {protocol}://{username}[:{password}@{host}/[{org}/]{repo}
  • [{username}[:{password}@]{host}:{org}/{repo}, example:
  • [file://]/[{org}/]*{repo}, example:
    • file:///path/to/your/repo
    • /org/repo

Note: current component user will be deprecated (but not removed to keep backward compatible), renamed to org.

@skoch13
Copy link

skoch13 commented Jan 6, 2024

@linrongbin16 correct, mine is set to ssh://[email protected]/%PROJECT_KEY%/%REPO%.git

@linrongbin16
Copy link
Owner Author

@linrongbin16 correct, mine is set to ssh://[email protected]/%PROJECT_KEY%/%REPO%.git

thanks!

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

Successfully merging a pull request may close this issue.

2 participants