Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Add 'y' shortcut to generate permalink to commit #267

Open
JonathonReinhart opened this issue Sep 12, 2022 · 4 comments
Open

Add 'y' shortcut to generate permalink to commit #267

JonathonReinhart opened this issue Sep 12, 2022 · 4 comments

Comments

@JonathonReinhart
Copy link

Problem

Frequently, people will share a link to a specific line of code in a file (e.g. a function name). However, this will usually be done on the main branch, which is likely to move. When the file contents change, the link may no longer point to the same line.

Solution

Both GitHub and GitLab support pressing y to generate a permalink. When a user presses y the URL in the address bar is updated with the ref (branch or tag) being replaced with the full commit SHA hash. This converts the URL into a "permalink". Note that a line number anchor is preserved.

Screen.recording.2022-09-12.10.35.19.webm
@JonathonReinhart
Copy link
Author

no fancy Javascript,

I missed this in the Gitiles description.

But, this workflow can still be enabled a couple of different ways.

Currently, when looking at a file, the following header is included:

blob: abcd1234abcd1234abcd1234abcd1234 [file] [log] [blame]
  1. At least show the current commit SHA for the current branch, particularly when displaying a file, so I can generate the URL myself. Today, Gitiles shows the blob hash, which isn't really useful.
  2. Add an additional [permalink] link, or update the existing [file] link to stick the resoled commit hash in the URL instead of the ref.

Without this, one has to navigate back to the ref page, and then copy/paste the commit hash from there, adding extra steps/commits.

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

No branches or pull requests

2 participants
@JonathonReinhart and others