Open kisaragi-hiu opened 1 year ago
@sshaw Is this ok to merge? I as well came across the issue where running (git-link)
in a magit-status: *
buffer prints Can't figure out where to link to
I as well came across the issue where running (git-link) in a magit-status: * buffer prints
In magit-status it will link to a file; if you're on the file. I.e., Staged/Unstged files. You want to link to something has no link but a link is generated anyways. Some may call this a bug. Which looks like the same outstanding question as last time
If you want to link to the homepage can you call git-link-homepage
?
Can link to file under point in Dired After ... Links to repository homepage instead in Dired when file under point is ..
Dired will work but yes, if you try to link to a parent directory outside the repo root then what is there to link to? I think a better default here would be the username page not the repos root because you're not trying to link to that: you're trying to link to the parent directory.
Under what circumstances would one generate a "cannot link to error" then?
This is most noticeable in magit-status, where you'd have to visit a random file to be able to jump to the repository page with git-link. In Dired, it's also noticeable if git-link is run when point isn't over a file, for instance on Dired's current directory heading.
This PR makes it so that, for example, running git-link in magit-status will fall back to visiting the repository at the current branch or commit. Then, as a special case, if current directory is project root (ie.
git-link--relative-filename
returns ""), visit the homepage instead.Now git-link in Magit and Dired always goes somewhere sensible, instead of returning an error.
Before
https://user-images.githubusercontent.com/11722318/228342018-2d653c35-1431-4170-bb35-48307991ccec.mp4
After
..
https://user-images.githubusercontent.com/11722318/228342537-5049cb9d-fbdb-410f-9b2d-f9b3aab4d9e6.mp4