vscode-git-graph icon indicating copy to clipboard operation
vscode-git-graph copied to clipboard

Feature Go To Commit

Open LaksVister opened this issue 8 months ago • 8 comments

This feature adds a special button on the top right that allows you to navigate to a specific commit in the Git Graph from Git Diff Compare Screenshot 2025-04-23 at 04 28 13

LaksVister avatar Apr 23 '25 02:04 LaksVister

Thanks for this PR. Generally a good idea, but it gives fuzzy results when viewing a diff of more than one commit. In case you have multiple changes in a file done by several commits - then it jumps only to the most recent commit. I can imagine that it could be extended in this way:

a) It jumps to the commit of the change where the cursor is located b) It could be done with the context menu (clicking on the changed line).

What do you think about that?

hansu avatar Apr 23 '25 19:04 hansu

I followed option b) and made a few more fixes

Screenshot 2025-04-24 at 23 33 09

LaksVister avatar Apr 24 '25 21:04 LaksVister

The context menu feature does not work unfortunately:

https://github.com/user-attachments/assets/c3877f7d-5819-442d-87f5-0fcf51434d76

hansu avatar Apr 24 '25 21:04 hansu

Oh, I have implemented the transition only between two files, go to the commit from the left file or go to the commit from the right file, if you narrow the two diff files to one file, then the URI of this file will be one and will contain only one commit, so I don't know how to fix it.

But as I see, you want another one, to implement the transition taking into account the commit line, that is, Line History, it is possible, it is available in GitLens, but not with my capabilities, it requires too many changes in the code and logic of Git Graph.

GitLens Example Screenshot 2025-04-25 at 01 39 00

LaksVister avatar Apr 24 '25 23:04 LaksVister

Hmm then I don't really know how your feature should be used. Can you provide an explanation (short video maybe)?

hansu avatar Apr 25 '25 07:04 hansu

Yes, it's simple, the feature performs the basic function of finding the commit of the file being compared. Here is an example video of how it is done without the feature and with the feature, instead of search manually, I created a button. If you want, I can add a more specific description like "Go to Commit this File"

https://github.com/user-attachments/assets/05dd58bb-3e99-4d36-9275-bec04346254a


What you suggest is already a separate feature, "Go to Commit this Line", and it needs a separate implementation function

LaksVister avatar Apr 25 '25 08:04 LaksVister

Ah ok now I understand the feature. It has a slightly rare use case. I could imagine using it in those two scenarios together with Git Lens:

https://github.com/user-attachments/assets/ceb5a9f8-7bb0-4681-901a-7c2f1f15a055

BUT when you are already using Git Lens, then you can also use the integrated functionality of Git Lens:

https://github.com/user-attachments/assets/26fc0540-e2a9-4266-bad9-aabe4d9c89e5

hansu avatar Apr 25 '25 09:04 hansu

I did this just to separate from Git Lens, I rarely use it lately, I even plan to remove Git Lens or replace it, it still has a convenient commit search and comparison of the two branches and it doesn't work in Workspaces (it gives an error), nevermind.

As for the Go To Commit feature, it can be used with any File History, for example build-in VS Code Timeline even has local commit changes. Very useful. Screenshot 2025-04-25 at 13 18 18

But I didn't have enough commit information to:

  1. See where this commit is in the graph
  2. See if there are changes to other files in the commit

That's why I use the Go To Commit button very often

LaksVister avatar Apr 25 '25 11:04 LaksVister