zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
49.68k stars 3.05k forks source link

GitHub permalink not working #13042

Closed eproxus closed 6 days ago

eproxus commented 5 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

  1. Open a Git repository with the following .git/config configuration:

    [remote "origin"]
       url = git@github.com:org/repo.git
  2. Choose editor: open permalink to line from the command palette
  3. See the following error message:

    Failed to open permalink: failed to parse Git remote URL

The same happens with ssh://github.com/org/repo.git.

Environment

Zed: v0.139.3 (Zed) OS: macOS 14.5.0 Memory: 64 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

maxdeviant commented 5 months ago

What is the output of git remote -v in the repository?

eproxus commented 5 months ago

Hmm, it actually is:

$ git remote -v
origin  github-work:org/repo.git (fetch)
origin  github-work:org/repo.git (push)

Which is because I have the following in my ~/.gitconfig:

[url "github-work:org/"]
    insteadOf = git@github.com:org/

If I remove that it works. The reason I have that config is because I have configured specific SSH settings for the github-work host in ~/.ssh/config.

donaldo-paktolus commented 3 months ago

I have the exact same issue

mfridman commented 2 months ago

Ah, didn't realize there was an issue ranking. There were a few 👀 on a similar discussion here https://github.com/zed-industries/zed/discussions/10215

notpeter commented 6 days ago

I believe ssh:// urls were fixed by:

It's not really practical for Zed to attempt to resolve a git remote which is re-written by .gitconfig to a fake host alias specified in ~/.ssh/config to detect whether the end host name is github.com.

I'm happy to revisit if you have a suggested method for how this could be implemented, but for now I'm going to close it as unactionable. Thanks for reporting.

tashi21 commented 13 hours ago

I'm also facing the same issue due to the same reason as @eproxus. @notpeter while I understand that currently it isn't supported or deemed as important, shouldn't this be implemented sometime in the future? I'm sure many people would have custom ssh configs for work repos. But if it is highly impractical for Zed to parse the ssh config to be able to resolve custom host names, what can we change in our configs to be able to get the same custom ssh config functionality AND use Zed's permalink feature?

Would it be too difficult to add a custom mapping of hostnames in the settings file for such a scenario that Zed can use to replace custom hosts with the actual underlying host? It can be a permalink specific setting, or a git related setting. Whichever results in a better and more practical implementation.

eproxus commented 13 hours ago

I've managed to solve it by removing the SSH host alias, so from my side the issue can be closed. For what it's worth, I personally don't think it is that strange to not require an editor to be aware of this kind of host mapping hack.