8000 Remote.PushUrl defaults to Remote.Url · GiTechLab/libgit2sharp@63afd18 · GitHub
[go: up one dir, main page]

Skip to content

Commit 63afd18

Browse files
author
Ryan Roden-Corrent
committed
Remote.PushUrl defaults to Remote.Url
1 parent 2cf68ce commit 63afd18

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

LibGit2Sharp.Tests/RemoteFixture.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public void CanSetRemoteUrl()
9191
r => r.Url = newUrl);
9292

9393
Assert.Equal(newUrl, updatedremote.Url);
94+
// with no push url set, PushUrl defaults to the fetch url
95+
Assert.Equal(newUrl, updatedremote.PushUrl);
9496
}
9597
}
9698

@@ -111,6 +113,8 @@ public void CanSetRemotePushUrl()
111113
Remote updatedremote = repo.Network.Remotes.Update(remote,
112114
r => r.PushUrl = pushurl);
113115

116+
// url should not change, push url should be set to new value
117+
Assert.Equal(url, updatedremote.Url);
114118
Assert.Equal(pushurl, updatedremote.PushUrl);
115119
}
116120
}

LibGit2Sharp/Remote.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class Remote : IEquatable<Remote>, IBelongToARepository
2020
internal readonly Repository repository;
2121

2222
private readonly RefSpecCollection refSpecs;
23+
private string pushUrl;
2324

2425
/// <summary>
2526
/// Needed for mocking purposes.
@@ -56,9 +57,18 @@ internal static Remote BuildFromPtr(RemoteSafeHandle handle, Repository repo)
5657

5758
/// <summary>
5859
/// Gets the distinct push url for this remote repository, if set.
59-
/// If no separate push url is specified, PushUrl is null.
60+
/// Defaults to the fetch url (<see cref="Url"/>) if not set.
6061
/// </summary>
61-
public virtual string PushUrl { get; private set; }
62+
public virtual string PushUrl {
63+
get
64+
{
65+
return pushUrl ?? Url;
66+
}
67+
private set
68+
{
69+
pushUrl = value;
70+
}
71+
}
6272

6373
/// <summary>
6474
/// Gets the Tag Fetch Mode of the remote - indicating how tags are fetched.

0 commit comments

Comments
 (0)
0