Skip to content

Commit 46a6279

Browse files
committed
Rename Delete to Remove in ReferenceCollection
1 parent e1ceed1 commit 46a6279

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

LibGit2Sharp.Tests/ReferenceFixture.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,30 +145,30 @@ public void AddWithNullStringThrows()
145145
}
146146

147147
[Fact]
148-
public void CanDeleteAReference()
148+
public void CanRemoveAReference()
149149
{
150150
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
151151
using (var repo = new Repository(path.RepositoryPath))
152152
{
153-
repo.Refs.Delete("refs/heads/packed");
153+
repo.Refs.Remove("refs/heads/packed");
154154
}
155155
}
156156

157157
[Fact]
158-
public void ADeletedReferenceCannotBeLookedUp()
158+
public void ARemovedReferenceCannotBeLookedUp()
159159
{
160160
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
161161
using (var repo = new Repository(path.RepositoryPath))
162162
{
163163
const string refName = "refs/heads/test";
164164

165-
repo.Refs.Delete(refName);
165+
repo.Refs.Remove(refName);
166166
Assert.Null(repo.Refs[refName]);
167167
}
168168
}
169169

170170
[Fact]
171-
public void DeletingAReferenceDecreasesTheRefsCount()
171+
public void RemovingAReferenceDecreasesTheRefsCount()
172172
{
173173
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
174174
using (var repo = new Repository(path.RepositoryPath))
@@ -178,7 +178,7 @@ public void DeletingAReferenceDecreasesTheRefsCount()
178178
List<string> refs = repo.Refs.Select(r => r.CanonicalName).ToList();
179179
Assert.True(refs.Contains(refName));
180180

181-
repo.Refs.Delete(refName);
181+
repo.Refs.Remove(refName);
182182

183183
List<string> refs2 = repo.Refs.Select(r => r.CanonicalName).ToList();
184184
Assert.False(refs2.Contains(refName));
@@ -188,20 +188,20 @@ public void DeletingAReferenceDecreasesTheRefsCount()
188188
}
189189

190190
[Fact]
191-
public void DeleteWithEmptyNameThrows()
191+
public void RemoveWithEmptyNameThrows()
192192
{
193193
using (var repo = new Repository(BareTestRepoPath))
194194
{
195-
Assert.Throws<ArgumentException>(() => repo.Refs.Delete(string.Empty));
195+
Assert.Throws<ArgumentException>(() => repo.Refs.Remove(string.Empty));
196196
}
197197
}
198198

199199
[Fact]
200-
public void DeleteWithNullNameThrows()
200+
public void RemoveWithNullNameThrows()
201201
{
202202
using (var repo = new Repository(BareTestRepoPath))
203203
{
204-
Assert.Throws<ArgumentNullException>(() => repo.Refs.Delete(null));
204+
Assert.Throws<ArgumentNullException>(() => repo.Refs.Remove(null));
205205
}
206206
}
207207

@@ -335,7 +335,7 @@ public void CanUpdateTargetOnSymbolicReference()
335335
newRef = (SymbolicReference)repo.Refs[newRef.CanonicalName];
336336
Assert.Equal(repo.Refs["refs/heads/test"].ResolveToDirectReference().Target, newRef.ResolveToDirectReference().Target);
337337

338-
repo.Refs.Delete(newRef.CanonicalName);
338+
repo.Refs.Remove(newRef.CanonicalName);
339339
}
340340
}
341341

@@ -371,7 +371,7 @@ public void UpdatingADirectRefWithSymbolFails()
371371
Assert.Throws<ArgumentException>(
372372
() => repo.Refs.UpdateTarget(newRef.CanonicalName, repo.Refs["refs/heads/test"].ResolveToDirectReference().Target.Sha));
373373

374-
repo.Refs.Delete(newRef.CanonicalName);
374+
repo.Refs.Remove(newRef.CanonicalName);
375375
}
376376
}
377377

LibGit2Sharp/ReferenceCollection.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private ObjectId Unabbreviate(ObjectId targetId)
141141
/// Delete a reference with the specified name
142142
/// </summary>
143143
/// <param name = "name">The name of the reference to delete.</param>
144-
public void Delete(string name)
144+
public void Remove(string name)
145145
{
146146
Ensure.ArgumentNotNullOrEmptyString(name, "name");
147147

@@ -156,6 +156,16 @@ public void Delete(string name)
156156
}
157157
}
158158

159+
/// <summary>
160+
/// Delete a reference with the specified name
161+
/// </summary>
162+
/// <param name = "name">The name of the reference to delete.</param>
163+
[Obsolete("This method will be removed in the next release. Please use Remove() instead.")]
164+
public void Delete(string name)
165+
{
166+
Remove(name);
167+
}
168+
159169
/// <summary>
160170
/// Rename an existing reference with a new name
161171
/// </summary>

0 commit comments

Comments
 (0)