-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Questionable behavior for open_file_url (GitBlameOpenFileURL) #103
Comments
I see; these are valid concerns, IMO. Thank you for the issue! @bossley9, any thoughts on this? Would implementing the suggestion (open at current line commit) be an issue in your workflow? Maybe it'd make sense to add a configuration option for the latest commit behavior 🤔 so that we have a default (current line commit) but still allow it to be modifiable without introducing new commands. |
That's a valid concern and I think that makes sense! The main concerns I see with this are
I was thinking there could be a fallback to try and get the latest remote commit and view with that instead, but it might lead to some invalid ranges (local remote has a file with 300 lines but the remote still only has 100 lines and selecting a line or range from the new commits would lead to unexpected behavior). Not sure what should be done in these scenarios 🤷 |
@nrako thoughts on this? I think it would make sense for git-blame to open to the current line commit, but you could still run into some 404s depending on what commits are pushed to the remote |
@bossley9 – I didn't knew range selection were supported, it would be nice if the commit summary msgs would appear for every selected line after a different delay (higher by default); but I digress that's a different topic. To answer your question, and as vaguely hinted in my initial msg, in both cases (range selected & lines not yet committed) the ref could try to fallback to the upstream branch. This would simply fail if there's no upstream branch and of course the lines could also be out of sync if the upstream branch is behind the local branch. But imho that'd still be more aligned with the "blame" context of this plugin and still somehow be a more resilient fallback than opening the file on the "last commit". To try getting the current upstream branch something like that should work: For anything more complex we could start to question wether such features starts to overlap with plugins such as:
I don't use them as I'd rather only have something simple that go straight to the "blame" context for the selected line(s) but there might be merits of considering delegating such features to other plugins. |
Actually I might start using https://github.com/linrongbin16/gitlinker.nvim as this is the closest to what I'd want; it supports range selection and check the existence of the upstream branch and the file on it. For There's probably some nice clues of how an "Open Github Blame" could work in that plugin too: |
You bring up some great points. Let me make sure I understand correctly, because this might be how we move forward with these command(s) in the future:
Is this desirable behavior for your purposes @nrako? I think these changes make sense for the project as a whole. I'm not sure how feasible implementing some of these changes are (there will likely be some difficulty/performance issues querying the remote, but we'll see!) but I want to make sure the best solution is implemented. The "last commit" behavior you mentioned is relatively new behavior, and I'm open to suggestion on it 🙂 |
I don't think it need to find the "latest upstream commit", this can simply goes to the upstream branch tree: e.g with Github: The plus side with this approach is that the user can realize that upstream is beyond and could push and refresh the webpage to see what he was expecting to see...
I didn't thought that far, but that could actually be a nice thing. |
Well actually, this makes me think that always trying to show the expected SHA could also be a desired behavior, especially for "blame" context, as a 404 becomes an indication that the user needs to push but then will be able to browse the code from the expected commit. Just food for thoughts, up to you. |
Yeah, it's really a matter of whether a 404 would be expected or not. In that case, let's remove the fallback behavior and let it behave as follows:
For all of these, we do not check if it exists upstream, we just provide the behavior and it would be up to the user to update their remote accordingly. These rules would also apply to |
Yeah, I like this behavior! I was thinking of using the latest (remote) for the second scenario, but using the most recent one makes more sense. I don't think we need to implement visual selections for |
Sounds good to me! |
sounds great to me! |
Awesome! I'll look into this in the next few days. I've also moved the other request into a new issue #106 so we can track it and hopefully work on it in the near future 🙂 |
The current behavior of
open_file_url
(:GitBlameOpenFileURL
) is opening the current file at the latest commit. However, most of the time the latest commit is not yet pushed to the remote web origin and this just open a 404 page. Making this command rather useless and confusing.Since the primary purpose of git-blame is to preview git message on every line (a git blame peek summary) I'd expect that
open_file_url
would use the current commit previewed instead of the latest commit. This could eventually fallback to the current branch if the current line is not committed or if multiple lines were selected (if that were supported).git-blame.nvim/lua/gitblame/init.lua
Lines 506 to 515 in 1f057f0
The text was updated successfully, but these errors were encountered: