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

Use correct repoUrl for credential #327

Merged
merged 1 commit into from
Oct 4, 2018
Merged

Conversation

jeschu1
Copy link
Member

@jeschu1 jeschu1 commented Oct 3, 2018

This change allows us to reinitialize the GitProcess with valid repository information and pass it correctly to the credential call.

The bug was caused by the refactor here.

  • Previously, we used the repoUrl from the enlistment on GitProcess creation.
  • Now, we use the url passed in on TryGetCredentials.

A new unit test was added that exposed the failure.

#289

@@ -47,11 +47,11 @@ public override IssueType HasIssue(List<string> messages)
// reinitialize the GitProcess with a valid repo url for 'git credential fill'
try
{
GVFSEnlistment enlistment = GVFSEnlistment.CreateFromDirectory(
this.Enlistment = GVFSEnlistment.CreateFromDirectory(
Copy link
Member Author

Choose a reason for hiding this comment

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

Alternatively I could grab the repoUrl off of enlistment and use it in the TryGetCredentials below. I'm not sure how much of a no no resetting this.Enlistment is, but in this case it is being updating to be correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

See my other comment. Given that you had to add a new set accessor, I would go with your other idea for the fix.

@jeschu1 jeschu1 requested a review from sanoursa October 3, 2018 15:54
@@ -37,7 +37,7 @@ public enum FixResult

protected ITracer Tracer { get; }
protected TextWriter Output { get; }
protected GVFSEnlistment Enlistment { get; }
protected GVFSEnlistment Enlistment { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Yea I definitely think we should keep the property readonly. In general, readonly state is much easier to reason about than mutable state.

@@ -47,11 +47,11 @@ public override IssueType HasIssue(List<string> messages)
// reinitialize the GitProcess with a valid repo url for 'git credential fill'
try
{
GVFSEnlistment enlistment = GVFSEnlistment.CreateFromDirectory(
this.Enlistment = GVFSEnlistment.CreateFromDirectory(
Copy link
Contributor

Choose a reason for hiding this comment

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

See my other comment. Given that you had to add a new set accessor, I would go with your other idea for the fix.

This change allows us to reinitialize the GitProces with valid repository information information and pass it correctly to the credential call.
{
this.Enlistment.UnmountGVFS();

this.Enlistment.Repair();
Copy link
Member

Choose a reason for hiding this comment

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

Do you know if the repair without the --confirm would have caught this as well? I was thinking that for each of our tests in this class would should run the repair without --confirm before running the confirm version to catch other possible code paths.

Copy link
Member Author

Choose a reason for hiding this comment

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

@kewillford , yes without --confirm we still get the error. It's up to us if we want to do another run without the flag. My only concern would be the length of time to run the tests, but if it's a test worth doing we should do it!

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking we could do it in the test cases we already have not adding new test cases.
Run repair without --confirm then run with it in the same test case. Hopefully this wouldn't add to much time.

Copy link
Member

@kewillford kewillford left a comment

Choose a reason for hiding this comment

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

Only question is if we can get better coverage by running the repair without --confirm in each test case.

Copy link
Contributor

@sanoursa sanoursa left a comment

Choose a reason for hiding this comment

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

Latest changes look good!

@jeschu1 jeschu1 merged commit f40e3d6 into microsoft:master Oct 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants