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
47.96k stars 2.83k forks source link

Git blame redirects to `origin` instead of `upstream` #13511

Open Peiffap opened 3 months ago

Peiffap commented 3 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

When hovering over the inline git blame for a given line inside Zed, the PR (and commit) link points to the (forked) origin repository rather than the upstream repository where the changes actually happened, which doesn't work.

Environment

Zed: v0.140.5 (Zed) OS: macOS 12.7.5 Memory: 8 GiB Architecture: x86_64

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

https://github.com/zed-industries/zed/assets/25282854/5f23de85-2241-41c0-b835-c822f58a5bc3

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

N/A

notpeter commented 3 months ago

Gotcha. Yeah the commits exist in your forked repo, but your fork has its own GitHub issues and so those links don't work.

I don't think there's any standardized way for us to determine which git remote should be used for as the URL_BASE for building PR/issue/commit URLs. We could hard code logic for origin/upstream by name but that definitely feels fragile and non-explicit.

Would love to know if any other editors are handling this gracefully (VSCode GitLens has the same behavior we do).

Peiffap commented 3 months ago

@notpeter Thanks for taking a look.

VSCode GitLens does this correctly for me.

https://github.com/zed-industries/zed/assets/25282854/b516f3ad-6d6c-4601-a487-b6fad20fbc3b

I'm not sure what their logic is, though.

notpeter commented 3 months ago

I wasn't logged into GitHub on GitLens (are you?). My guess is that it's using the Github API to determine if a repo is a source or fork. We would likely have to do the same.

Thanks for digging in.

Peiffap commented 3 months ago

I am logged in, and having checked on a PC where I am not, hovering over where the PR link should show up tells me "Connect to GitHub to enable the display of the Pull Request (if any) that introduced this commit". I'm assuming this is what you saw when you checked earlier (?).

Edit: re: the GitHub API, this is likely the relevant documentation.

ADKaster commented 2 months ago

In CLion, right clicking on the git blame gutter lets me select which remote to open the commit in. Something like this, or a setting to at least set the 'default remote' to open would be great.

image