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

Commit d1ca52c

Browse files
committed
Update to use UriString.RepositoryUrlsAreEqual
1 parent 3cdd1f6 commit d1ca52c

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

src/GitHub.App/Services/GitClient.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,9 @@ public Task Fetch(IRepository repository, string remoteName)
9696

9797
public Task Fetch(IRepository repo, UriString cloneUrl, params string[] refspecs)
9898
{
99-
var httpsString = cloneUrl.ToRepositoryUrl().ToString();
100-
10199
foreach (var remote in repo.Network.Remotes)
102100
{
103-
var remoteUrl = new UriString(remote.Url);
104-
if (!remoteUrl.IsHypertextTransferProtocol)
105-
{
106-
// Only match http urls
107-
continue;
108-
}
109-
110-
var remoteHttpsString = remoteUrl.ToRepositoryUrl().ToString();
111-
if (remoteHttpsString.Equals(httpsString, StringComparison.OrdinalIgnoreCase))
101+
if (UriString.RepositoryUrlsAreEqual(new UriString(remote.Url), cloneUrl))
112102
{
113103
return Fetch(repo, remote.Name, refspecs);
114104
}
@@ -128,7 +118,7 @@ public Task Fetch(IRepository repo, UriString cloneUrl, params string[] refspecs
128118
removeRemote = true;
129119
}
130120

131-
var remote = repo.Network.Remotes.Add(remoteName, httpsString);
121+
var remote = repo.Network.Remotes.Add(remoteName, cloneUrl);
132122
try
133123
{
134124
#pragma warning disable 0618 // TODO: Replace `Network.Fetch` with `Commands.Fetch`.

src/GitHub.App/Services/PullRequestService.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -568,11 +568,7 @@ async Task<string> CreateRemote(IRepository repo, UriString cloneUri)
568568
{
569569
foreach (var remote in repo.Network.Remotes)
570570
{
571-
// Compare Urls ignoring case and any trailing ".git"
572-
if (string.Equals(
573-
new UriString(remote.Url).ToRepositoryUrl().ToString(),
574-
cloneUri.ToRepositoryUrl().ToString(),
575-
StringComparison.OrdinalIgnoreCase))
571+
if (UriString.RepositoryUrlsAreEqual(new UriString(remote.Url), cloneUri))
576572
{
577573
return remote.Name;
578574
}

0 commit comments

Comments
 (0)