Skip to content

Commit 293f26e

Browse files
committed
Rename Delete to Unset in Configuration
1 parent 1ed8a4f commit 293f26e

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

LibGit2Sharp.Tests/ConfigurationFixture.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private static void AssertValueInGlobalConfigFile(string regex)
4444
}
4545

4646
[Fact]
47-
public void CanDeleteAnEntryFromTheLocalConfiguration()
47+
public void CanUnsetAnEntryFromTheLocalConfiguration()
4848
{
4949
var path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);
5050
using (var repo = new Repository(path.RepositoryPath))
@@ -54,14 +54,14 @@ public void CanDeleteAnEntryFromTheLocalConfiguration()
5454
repo.Config.Set("unittests.boolsetting", true);
5555
Assert.True(repo.Config.Get<bool>("unittests.boolsetting", false));
5656

57-
repo.Config.Delete("unittests.boolsetting");
57+
repo.Config.Unset("unittests.boolsetting");
5858

5959
Assert.False(repo.Config.Get<bool>("unittests.boolsetting", false));
6060
}
6161
}
6262

6363
[Fact]
64-
public void CanDeleteAnEntryFromTheGlobalConfiguration()
64+
public void CanUnsetAnEntryFromTheGlobalConfiguration()
6565
{
6666
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
6767

@@ -88,10 +88,10 @@ public void CanDeleteAnEntryFromTheGlobalConfiguration()
8888
Assert.True(repo.Config.HasGlobalConfig);
8989
Assert.Equal(42, repo.Config.Get("Wow.Man-I-am-totally-global", 1337));
9090

91-
repo.Config.Delete("Wow.Man-I-am-totally-global");
91+
repo.Config.Unset("Wow.Man-I-am-totally-global");
9292
Assert.Equal(42, repo.Config.Get("Wow.Man-I-am-totally-global", 1337));
9393

94-
repo.Config.Delete("Wow.Man-I-am-totally-global", ConfigurationLevel.Global);
94+
repo.Config.Unset("Wow.Man-I-am-totally-global", ConfigurationLevel.Global);
9595
Assert.Equal(1337, repo.Config.Get("Wow.Man-I-am-totally-global", 1337));
9696
}
9797
}

LibGit2Sharp/Configuration.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ public void Dispose()
139139
#endregion
140140

141141
/// <summary>
142-
/// Delete a configuration variable (key and value).
142+
/// Unset a configuration variable (key and value).
143143
/// </summary>
144-
/// <param name = "key">The key to delete.</param>
144+
/// <param name = "key">The key to unset.</param>
145145
/// <param name = "level">The configuration file which should be considered as the target of this operation</param>
146-
public void Delete(string key, ConfigurationLevel level = ConfigurationLevel.Local)
146+
public void Unset(string key, ConfigurationLevel level = ConfigurationLevel.Local)
147147
{
148148
ConfigurationSafeHandle h = RetrieveConfigurationHandle(level);
149149

@@ -158,6 +158,17 @@ public void Delete(string key, ConfigurationLevel level = ConfigurationLevel.Loc
158158
Save();
159159
}
160160

161+
/// <summary>
162+
/// Delete a configuration variable (key and value).
163+
/// </summary>
164+
/// <param name = "key">The key to delete.</param>
165+
/// <param name = "level">The configuration file which should be considered as the target of this operation</param>
166+
[Obsolete("This method will be removed in the next release. Please use Unset() instead.")]
167+
public void Delete(string key, ConfigurationLevel level = ConfigurationLevel.Local)
168+
{
169+
Unset(key, level);
170+
}
171+
161172
/// <summary>
162173
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
163174
/// </summary>

0 commit comments

Comments
 (0)