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

Commit 8d457db

Browse files
committed
Change from using deprecated Branch.Remote to Branch.RemoteName
1 parent c54fc89 commit 8d457db

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

src/GitHub.App/Services/PullRequestService.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ public IObservable<Unit> Push(ILocalRepositoryModel repository)
106106
return Observable.Defer(async () =>
107107
{
108108
var repo = gitService.GetRepository(repository.LocalPath);
109-
#pragma warning disable 0618 // Branch.Remote is deprecated
110-
var remoteName = repo.Head.Remote.Name;
111-
#pragma warning restore 0618
109+
var remoteName = repo.Head.RemoteName;
112110
var remote = await gitClient.GetHttpRemote(repo, remoteName);
113111
return gitClient.Push(repo, repo.Head.TrackedBranch.UpstreamBranchCanonicalName, remote.Name).ToObservable();
114112
});
@@ -369,12 +367,10 @@ public IObservable<Unit> RemoveUnusedRemotes(ILocalRepositoryModel repository)
369367
return Observable.Defer(async () =>
370368
{
371369
var repo = gitService.GetRepository(repository.LocalPath);
372-
#pragma warning disable 0618 // Branch.Remote is deprecated
373370
var usedRemotes = new HashSet<string>(
374371
repo.Branches
375-
.Where(x => !x.IsRemote && x.Remote != null)
376-
.Select(x => x.Remote?.Name));
377-
#pragma warning restore 0618
372+
.Where(x => !x.IsRemote && x.RemoteName != null)
373+
.Select(x => x.RemoteName));
378374

379375
foreach (var remote in repo.Network.Remotes)
380376
{

src/UnitTests/GitHub.App/Services/PullRequestServiceTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,8 @@ public async Task ShouldRemoveUnusedRemote()
524524
var branch2 = Substitute.For<LibGit2Sharp.Branch>();
525525
var branches = new List<LibGit2Sharp.Branch> { branch1, branch2 };
526526
var branchCollection = Substitute.For<BranchCollection>();
527-
branch1.Remote.Returns(remote1);
528-
branch2.Remote.Returns(remote1);
527+
branch1.RemoteName.Returns("remote1");
528+
branch2.RemoteName.Returns("remote1");
529529
branchCollection.GetEnumerator().Returns(_ => branches.GetEnumerator());
530530
repo.Branches.Returns(branchCollection);
531531

0 commit comments

Comments
 (0)