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

Commit 8b17782

Browse files
committed
Use IRepository returned by GetActiveRepo inside using
1 parent 6f1a890 commit 8b17782

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/GitHub.App/Services/RepositoryPublishService.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ public string LocalRepositoryName
2626
{
2727
get
2828
{
29-
var activeRepo = vsGitServices.GetActiveRepo();
30-
if (!string.IsNullOrEmpty(activeRepo?.Info?.WorkingDirectory))
31-
return new DirectoryInfo(activeRepo.Info.WorkingDirectory).Name ?? "";
32-
return string.Empty;
29+
using (var activeRepo = vsGitServices.GetActiveRepo())
30+
{
31+
if (!string.IsNullOrEmpty(activeRepo?.Info?.WorkingDirectory))
32+
return new DirectoryInfo(activeRepo.Info.WorkingDirectory).Name ?? "";
33+
return string.Empty;
34+
}
3335
}
3436
}
3537

@@ -43,11 +45,14 @@ public string LocalRepositoryName
4345
.Select(remoteRepo => new { RemoteRepo = remoteRepo, LocalRepo = vsGitServices.GetActiveRepo() }))
4446
.SelectMany(async repo =>
4547
{
46-
await gitClient.SetRemote(repo.LocalRepo, "origin", new Uri(repo.RemoteRepo.CloneUrl));
47-
await gitClient.Push(repo.LocalRepo, "master", "origin");
48-
await gitClient.Fetch(repo.LocalRepo, "origin");
49-
await gitClient.SetTrackingBranch(repo.LocalRepo, "master", "origin");
50-
return repo.RemoteRepo;
48+
using (repo.LocalRepo)
49+
{
50+
await gitClient.SetRemote(repo.LocalRepo, "origin", new Uri(repo.RemoteRepo.CloneUrl));
51+
await gitClient.Push(repo.LocalRepo, "master", "origin");
52+
await gitClient.Fetch(repo.LocalRepo, "origin");
53+
await gitClient.SetTrackingBranch(repo.LocalRepo, "master", "origin");
54+
return repo.RemoteRepo;
55+
}
5156
});
5257
}
5358
}

0 commit comments

Comments
 (0)