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

Commit d4a7489

Browse files
committed
Introduce Remote.IsValidName(string)
Deprecate RemoteCollection.IsValidName(string). Update test CanTellIfARemoteNameIsValid(string, bool). Fixes libgit2#679
1 parent 35e9a66 commit d4a7489

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

LibGit2Sharp.Tests/RemoteFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public void CanTellIfARemoteNameIsValid(string refname, bool expectedResult)
153153
{
154154
using (var repo = new Repository(BareTestRepoPath))
155155
{
156-
Assert.Equal(expectedResult, repo.Network.Remotes.IsValidName(refname));
156+
Assert.Equal(expectedResult, Remote.IsValidName(refname));
157157
}
158158
}
159159

LibGit2Sharp/Remote.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ internal string FetchSpecTransformToSource(string reference)
9595
}
9696
}
9797

98+
/// <summary>
99+
/// Determines if the proposed remote name is well-formed.
100+
/// </summary>
101+
/// <param name="name">The name to be checked.</param>
102+
/// <returns>true is the name is valid; false otherwise.</returns>
103+
public static bool IsValidName(string name)
104+
{
105+
return Proxy.git_remote_is_valid_name(name);
106+
}
107+
98108
/// <summary>
99109
/// Determines whether the specified <see cref="Object"/> is equal to the current <see cref="Remote"/>.
100110
/// </summary>

LibGit2Sharp/RemoteCollection.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,10 @@ public virtual Remote Add(string name, string url, string fetchRefSpec)
131131
/// </summary>
132132
/// <param name="name">The name to be checked.</param>
133133
/// <returns>true is the name is valid; false otherwise.</returns>
134+
[Obsolete("This method will be removed in the next release. Please use Remote.IsValidName(string) instead.")]
134135
public virtual bool IsValidName(string name)
135136
{
136-
return Proxy.git_remote_is_valid_name(name);
137+
return Remote.IsValidName(name);
137138
}
138139

139140
private string DebuggerDisplay

0 commit comments

Comments
 (0)