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

Commit 12c1c9f

Browse files
committed
Add using to avoid crash in Release mode
Somehow putting the `repo` object in a `using` avoids the following issue: #1306
1 parent 10cc6d4 commit 12c1c9f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/GitHub.App/Services/PullRequestService.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
using System.Reactive;
1515
using System.Collections.Generic;
1616
using LibGit2Sharp;
17-
using System.Diagnostics;
1817
using GitHub.Logging;
18+
using Serilog;
1919

2020
namespace GitHub.Services
2121
{
@@ -102,9 +102,14 @@ public IObservable<IReadOnlyList<CommitMessage>> GetMessagesForUniqueCommits(
102102

103103
public IObservable<bool> IsWorkingDirectoryClean(ILocalRepositoryModel repository)
104104
{
105-
var repo = gitService.GetRepository(repository.LocalPath);
106-
var isClean = !IsFilthy(repo.RetrieveStatus());
107-
return Observable.Return(isClean);
105+
// The `using` appears to resolve this issue:
106+
// https://github.com/github/VisualStudio/issues/1306
107+
using (var repo = gitService.GetRepository(repository.LocalPath))
108+
{
109+
var status = repo.RetrieveStatus();
110+
var isClean = !IsFilthy(status);
111+
return Observable.Return(isClean);
112+
}
108113
}
109114

110115
static bool IsFilthy(RepositoryStatus status)
@@ -271,7 +276,7 @@ public IObservable<Unit> SwitchToBranch(ILocalRepositoryModel repository, IPullR
271276
var repo = gitService.GetRepository(repository.LocalPath);
272277
var branchName = GetLocalBranchesInternal(repository, repo, pullRequest).FirstOrDefault();
273278

274-
Log.Assert(branchName != null, "PullRequestService.SwitchToBranch called but no local branch found");
279+
Logging.Log.Assert(branchName != null, "PullRequestService.SwitchToBranch called but no local branch found");
275280

276281
if (branchName != null)
277282
{

0 commit comments

Comments
 (0)