Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Conversation

@jcansdale
Copy link
Collaborator

@jcansdale jcansdale commented Jul 17, 2018

What this PR does

Extend the GoToSolutionOrPullRequestFile command to support navigation from a file opened using the history view to the same file in the users solution/working directory.

How to test

The history of a file

  1. Right click on a source file from a repository and Code context > View History...
    image

  2. Double click on a revision in the history
    image

  3. Right click on the read-only historical file and Open File in Solution
    image

  4. It should navigate to the equivalent position in your solution / working directory

The commit history

  1. Select View History... from the status bar
    image

  2. Double click on a commit in the history
    image

  3. Double click on a changed file in the commit
    image

  4. Right click on the commit diff view and Open File in Solution
    image

  5. It should navigate to the equivalent position in your solution / working directory

Extend the GoToSolutionOrPullRequestFile command to support navigation
from a file opened using the history view to the same file in the users
solution/working directory.
@jcansdale jcansdale changed the title [wip] Enable navigation from historical file to solution Enable navigation from historical file to solution Jul 18, 2018
@StanleyGoldman StanleyGoldman self-requested a review July 27, 2018 13:40
var match = tempFileObjectishRegex.Match(tempFile);
if (match.Success)
{
return match.Groups["objectish"].Value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you name the group objectish?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's not you, that's just what the value is called in RepoExtensions.Lookup(...). Nvm me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(first 8 chars of a blob SHA) ahh

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It started off being called blobish, but I stole the name from the Lookup method you found. 😄

foreach (var commit in repo.Commits)
{
var trees = new Stack<Tree>();
trees.Push(commit.Tree);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now know what a Git blob sha is, I've yet to wrap my head around a Commit Tree.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to read the tests more

Copy link
Contributor

@StanleyGoldman StanleyGoldman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something small to refactor..

if (objectish == null)
{
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first three if statements from this function and the function above are meant to be the same.
The only minor minor difference (took me a moment to spot) is you are saving the repository dir in the second implementation.

The intent might be clearer if you combine both to one function that returns repositoryDir if the conditions are right or null if they fail.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetRepositoryDirectoryForSourceViewAndPath or something..

@StanleyGoldman
Copy link
Contributor

Everything works here. Just one thing that can be clarified i spotted.
I still feel like I need to read the tests more to understand what a Commit Tree is.

Factored out FindObjectishForTFSTempFile and added comments.
@StanleyGoldman StanleyGoldman merged commit dffdf45 into master Aug 4, 2018
@StanleyGoldman StanleyGoldman deleted the feature/navigate-from-history-to-working-directory branch August 4, 2018 01:45
@meaghanlewis meaghanlewis added this to the 2.5.5 milestone Aug 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants