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

Fix crash when on deleted PR branch #1082

Merged
merged 4 commits into from Jul 27, 2017

Conversation

Projects
None yet
3 participants
@jcansdale
Contributor

jcansdale commented Jul 19, 2017

Visual Studio was crashing when the branch for a PR was deleted.

This PR makes IsHeadPushed return false when IsTracking is true but the branch has since been deleted.

To repro this issue:

  1. Open GitHub tool window and show Closed PRs.
  2. Checkout any PR that is on a deleted branch (most closed PRs)
  • If solution isn't open you will see:
    image
  • If solution is open, Visual Studio will crash.
    image

Fixes #1081

Make `IsHeadPushed` return false when on deleted branch
This was throwing and causing Visual Studio to crash.

@jcansdale jcansdale requested review from paladique and grokys Jul 20, 2017

@jcansdale jcansdale requested a review from shana Jul 27, 2017

Show outdated Hide outdated src/GitHub.App/Services/GitClient.cs
@@ -390,7 +390,16 @@ public Task<bool> IsHeadPushed(IRepository repo)
{
return Task.Factory.StartNew(() =>
{
return repo.Head.IsTracking && repo.Head.Tip.Sha == repo.Head.TrackedBranch.Tip.Sha;
if(repo.Head.IsTracking)

This comment has been minimized.

@shana

shana Jul 27, 2017

Collaborator

@shana

shana Jul 27, 2017

Collaborator

Show outdated Hide outdated src/GitHub.App/Services/GitClient.cs
if(repo.Head.IsTracking)
{
var trackedBranchTip = repo.Head.TrackedBranch.Tip;
if(trackedBranchTip != null)

This comment has been minimized.

@shana

shana Jul 27, 2017

Collaborator

@shana

shana Jul 27, 2017

Collaborator

Show outdated Hide outdated src/UnitTests/GitHub.App/Services/GitClientTests.cs
static Commit MockCommitOrNull(string sha)
{
if(sha != null)

This comment has been minimized.

@shana

shana Jul 27, 2017

Collaborator

@shana

shana Jul 27, 2017

Collaborator

jcansdale added some commits Jul 27, 2017

@@ -143,7 +188,7 @@ static IRepository MockRepo(string baseSha, string headSha, string mergeBaseSha)
var mergeBaseCommit = Substitute.For<Commit>();
mergeBaseCommit.Sha.Returns(mergeBaseSha);
if(baseSha != null)
if (baseSha != null)

This comment has been minimized.

@shana

shana Jul 27, 2017

Collaborator

👏

@shana

shana Jul 27, 2017

Collaborator

👏

@shana

shana approved these changes Jul 27, 2017

@shana

This comment has been minimized.

Show comment
Hide comment
@shana

shana Jul 27, 2017

Collaborator

Collaborator

shana commented Jul 27, 2017

@jcansdale jcansdale merged commit 02020aa into master Jul 27, 2017

5 checks passed

GitHub CLA @jcansdale has accepted the GitHub Contributor License Agreement.
Details
VisualStudio Build #7433964 succeeded in 102s
Details
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
jenkins/build_log Jenkins Build Log
Details

@jcansdale jcansdale deleted the fixes/1081-on-deleted-branch branch Jul 27, 2017

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