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

feature: gitbrowse: support copying/opening permanent link URL #320

Open
1 task done
krshrimali opened this issue Dec 16, 2024 · 2 comments
Open
1 task done

feature: gitbrowse: support copying/opening permanent link URL #320

krshrimali opened this issue Dec 16, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@krshrimali
Copy link

Did you check the docs?

  • I have read all the snacks.nvim docs

Is your feature request related to a problem? Please describe.

In general, when copying the URL, for many - it might make more sense to share the permanent link to avoid any surprises later. Sharing just the file URL might just become invalid/incorrect if any commit (later) changes the corresponding file/piece of code.

Being able to share the permanent link would help solve this problem.

Describe the solution you'd like

Design: (user-facing) Having an option with what='permalink' or something similar would help.

The URL pattern, for at least GitHub would look like:

...
permalink = "/blob/{commit_hash}/{file}#L{line_start}-L{lne_end},
...

Implementation (dev-facing): commit_hash would store the output of system({ "git", "-C", cwd, "rev-parse", "HEAD" }, "Failed to get current commit")[1]. We'll probably need something similar for bitbucket/others (I've not tested them yet, can do once this is approved).

Describe alternatives you've considered

I tried passing the commit to the URL patterns from the user side, but then realised that commit variable does not really store the commit has value. Was my bad, I'm not aware of any other alternatives with this plugin.

Additional context

I'll be happy to help create a PR if this feature request sounds reasonable to the maintainers. Thanks for the amazing work!

@krshrimali krshrimali added the enhancement New feature or request label Dec 16, 2024
@krshrimali
Copy link
Author

Hi, @folke - Apologies for the ping, just curious - does this sound like a feature that you'd like to have in gitbrowse? If yes, I'll be happy to send the patch over.

@folke
Copy link
Owner

folke commented Dec 18, 2024

Feel free to create a PR. ty

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

No branches or pull requests

2 participants