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

feat(gitbrowse): get commit hash from current line on open #1381

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

whoop-t
Copy link

@whoop-t whoop-t commented Feb 22, 2025

Description

Allow gitbrowse to get the current line commit hash when using Snacks.gitbrowse.open()

Related Issue(s)

Currently you must hover the word of the actually commit hash. This requires you opening git blame(or something similar) and hovering the word of the commit hash you want to open.

I feel like this is kind of clunky and would it would be nicer to just be able to open commit url straight from file/line.

@whoop-t
Copy link
Author

whoop-t commented Feb 22, 2025

Similar to: #393

@dpetka2001
Copy link
Contributor

How would you open file/branch/repo then?

@whoop-t
Copy link
Author

whoop-t commented Feb 23, 2025

How would you open file/branch/repo then?

You would change the what in the opts, commit should still just fallback like it already does.

I altered it a bit: 31ebdb4

@dpetka2001
Copy link
Contributor

if not fields.commit and (opts.what == "commit" or opts.what == "permalink") then
opts.what = "file"
end
if not fields.commit and not fields.file then
opts.what = "branch"
end
if not fields.commit and not fields.branch then
opts.what = "repo"
end

These will never execute if you always set fields.commit. It's supposed to automatically switch the opts.what based on the content under the cursor without the user having to explicitly specify it.

#1371 will expose opts.commit and then users can implement this logic in their personal configuration if they want to.

@whoop-t
Copy link
Author

whoop-t commented Feb 23, 2025

@dpetka2001 I guess then what's the point of setting what = "commit" if it just does stuff automatically.

Why not have another option like auto or something?

Without looking at the code it's kinda unclear what it will do when setting it to commit

@dpetka2001
Copy link
Contributor

what = "commit" is just the starting point and based on the context under the cursor it changes automatically if needed or not. You're supposed to put your cursor somewhere and based on that the appropriate action is taken. You're supposed to put the cursor on top of a commit sha if you want to trigger that action.

Anyhow, maintainer has the final say. I'm just a simple user.

@whoop-t
Copy link
Author

whoop-t commented Feb 23, 2025

@dpetka2001 Its all good, this isnt super important but thought it was worth a discussion.

No where does it say you need to hover a commit sha for what = "commit"(the default setting) to work(unless you look at the code) so I think that will cause confusion. Im just coming from another plugin that if you say "i want to open the commit", thats what it does.

Maybe just a note somewhere as this confused me till I looked at the code.

Thanks for the back and forth

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

Successfully merging this pull request may close these issues.

2 participants