Skip to content

Create/Delete to Add/Remove #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions LibGit2Sharp.Tests/BranchFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void CanCreateBranch(string name)
Assert.Equal("be3563ae3f795b2b4353bcce3a527ad0a4f7f644", newBranch.Tip.Sha);
Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name == name));

repo.Branches.Delete(newBranch.Name);
repo.Branches.Remove(newBranch.Name);
}
}

Expand Down Expand Up @@ -136,7 +136,7 @@ public void CreatingBranchWithUnknownNamedTargetThrows()
{
using (var repo = new Repository(BareTestRepoPath))
{
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Create("my_new_branch", "my_old_branch"));
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Add("my_new_branch", "my_old_branch"));
}
}

Expand All @@ -145,8 +145,8 @@ public void CreatingBranchWithUnknownShaTargetThrows()
{
using (var repo = new Repository(BareTestRepoPath))
{
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Create("my_new_branch", Constants.UnknownSha));
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Create("my_new_branch", Constants.UnknownSha.Substring(0, 7)));
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Add("my_new_branch", Constants.UnknownSha));
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Add("my_new_branch", Constants.UnknownSha.Substring(0, 7)));
}
}

Expand All @@ -155,7 +155,7 @@ public void CreatingABranchPointingAtANonCanonicalReferenceThrows()
{
using (var repo = new Repository(BareTestRepoPath))
{
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Create("nocanonicaltarget", "br2"));
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Add("nocanonicaltarget", "br2"));
}
}

Expand All @@ -164,10 +164,10 @@ public void CreatingBranchWithBadParamsThrows()
{
using (var repo = new Repository(BareTestRepoPath))
{
Assert.Throws<ArgumentNullException>(() => repo.Branches.Create(null, repo.Head.CanonicalName));
Assert.Throws<ArgumentException>(() => repo.Branches.Create(string.Empty, repo.Head.CanonicalName));
Assert.Throws<ArgumentNullException>(() => repo.Branches.Create("bad_branch", default(string)));
Assert.Throws<ArgumentException>(() => repo.Branches.Create("bad_branch", string.Empty));
Assert.Throws<ArgumentNullException>(() => repo.Branches.Add(null, repo.Head.CanonicalName));
Assert.Throws<ArgumentException>(() => repo.Branches.Add(string.Empty, repo.Head.CanonicalName));
Assert.Throws<ArgumentNullException>(() => repo.Branches.Add("bad_branch", default(string)));
Assert.Throws<ArgumentException>(() => repo.Branches.Add("bad_branch", string.Empty));
Assert.Throws<ArgumentNullException>(() => repo.CreateBranch("bad_branch", default(Commit)));
}
}
Expand Down Expand Up @@ -429,18 +429,18 @@ public void CheckingOutABranchWithBadParamsThrows()
}
}

private void AssertDeletion(string branchName, bool isRemote, bool shouldPrevisoulyAssertExistence)
private void AssertRemoval(string branchName, bool isRemote, bool shouldPreviouslyAssertExistence)
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);

using (var repo = new Repository(path.RepositoryPath))
{
if (shouldPrevisoulyAssertExistence)
if (shouldPreviouslyAssertExistence)
{
Assert.NotNull(repo.Branches[branchName]);
}

repo.Branches.Delete(branchName, isRemote);
repo.Branches.Remove(branchName, isRemote);
Branch branch = repo.Branches[branchName];
Assert.Null(branch);
}
Expand All @@ -449,36 +449,36 @@ private void AssertDeletion(string branchName, bool isRemote, bool shouldPreviso
[Theory]
[InlineData("i-do-numbers", false)]
[InlineData("origin/br2", true)]
public void CanDeleteAnExistingBranch(string branchName, bool isRemote)
public void CanRemoveAnExistingBranch(string branchName, bool isRemote)
{
AssertDeletion(branchName, isRemote, true);
AssertRemoval(branchName, isRemote, true);
}


[Theory]
[InlineData("I-donot-exist", false)]
[InlineData("me/neither", true)]
public void CanDeleteANonExistingBranch(string branchName, bool isRemote)
public void CanRemoveANonExistingBranch(string branchName, bool isRemote)
{
AssertDeletion(branchName, isRemote, false);
AssertRemoval(branchName, isRemote, false);
}

[Fact]
public void DeletingABranchWhichIsTheCurrentHeadThrows()
public void RemovingABranchWhichIsTheCurrentHeadThrows()
{
using (var repo = new Repository(BareTestRepoPath))
{
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Delete(repo.Head.Name));
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Remove(repo.Head.Name));
}
}

[Fact]
public void DeletingABranchWithBadParamsThrows()
public void RemovingABranchWithBadParamsThrows()
{
using (var repo = new Repository(BareTestRepoPath))
{
Assert.Throws<ArgumentException>(() => repo.Branches.Delete(string.Empty));
Assert.Throws<ArgumentNullException>(() => repo.Branches.Delete(null));
Assert.Throws<ArgumentException>(() => repo.Branches.Remove(string.Empty));
Assert.Throws<ArgumentNullException>(() => repo.Branches.Remove(null));
}
}

Expand Down Expand Up @@ -519,7 +519,7 @@ public void TwoBranchesPointingAtTheSameCommitAreNotBothCurrent()
{
Branch master = repo.Branches["refs/heads/master"];

Branch newBranch = repo.Branches.Create("clone-of-master", master.Tip.Sha);
Branch newBranch = repo.Branches.Add("clone-of-master", master.Tip.Sha);
Assert.False(newBranch.IsCurrentRepositoryHead);
}
}
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp.Tests/CommitFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void CanEnumerateCommitsInDetachedHeadState()
{
ObjectId parentOfHead = repo.Head.Tip.Parents.First().Id;

repo.Refs.Create("HEAD", parentOfHead.Sha, true);
repo.Refs.Add("HEAD", parentOfHead.Sha, true);
Assert.Equal(true, repo.Info.IsHeadDetached);

Assert.Equal(6, repo.Commits.Count());
Expand Down Expand Up @@ -341,7 +341,7 @@ private static void AssertEnumerationOfCommits(Func<Repository, Filter> filterBu

private static void AssertEnumerationOfCommitsInRepo(Repository repo, Func<Repository, Filter> filterBuilder, IEnumerable<string> abbrevIds)
{
ICommitCollection commits = repo.Commits.QueryBy(filterBuilder(repo));
ICommitLog commits = repo.Commits.QueryBy(filterBuilder(repo));

IEnumerable<string> commitShas = commits.Select(c => c.Id.ToString(7)).ToArray();

Expand Down
10 changes: 5 additions & 5 deletions LibGit2Sharp.Tests/ConfigurationFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static void AssertValueInGlobalConfigFile(string regex)
}

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

repo.Config.Delete("unittests.boolsetting");
repo.Config.Unset("unittests.boolsetting");

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

[Fact]
public void CanDeleteAnEntryFromTheGlobalConfiguration()
public void CanUnsetAnEntryFromTheGlobalConfiguration()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();

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

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

repo.Config.Delete("Wow.Man-I-am-totally-global", ConfigurationLevel.Global);
repo.Config.Unset("Wow.Man-I-am-totally-global", ConfigurationLevel.Global);
Assert.Equal(1337, repo.Config.Get("Wow.Man-I-am-totally-global", 1337));
}
}
Expand Down
22 changes: 11 additions & 11 deletions LibGit2Sharp.Tests/NoteFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,20 @@ public void CanAccessNotesFromACommit()
Assert.Equal(expectedNamespaces, commit.Notes.Select(n => n.Message));

// Make sure that Commit.Notes is not refreshed automatically
repo.Notes.Create(commit.Id, "I'm batman!\n", signatureNullToken, signatureYorah, "batmobile");
repo.Notes.Add(commit.Id, "I'm batman!\n", signatureNullToken, signatureYorah, "batmobile");

Assert.Equal(expectedNamespaces, commit.Notes.Select(n => n.Message));
}
}

[Fact]
public void CanCreateANoteOnAGitObject()
public void CanAddANoteOnAGitObject()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
using (var repo = new Repository(path.RepositoryPath))
{
var commit = repo.Lookup<Commit>("9fd738e8f7967c078dceed8190330fc8648ee56a");
var note = repo.Notes.Create(commit.Id, "I'm batman!\n", signatureNullToken, signatureYorah, "batmobile");
var note = repo.Notes.Add(commit.Id, "I'm batman!\n", signatureNullToken, signatureYorah, "batmobile");

var newNote = commit.Notes.Single();
Assert.Equal(note, newNote);
Expand All @@ -140,7 +140,7 @@ public void CreatingANoteWhichAlreadyExistsOverwritesThePreviousNote()
var commit = repo.Lookup<Commit>("5b5b025afb0b4c913b4c338a42934a3863bf3644");
Assert.NotNull(commit.Notes.FirstOrDefault(x => x.Namespace == "answer"));

repo.Notes.Create(commit.Id, "I'm batman!\n", signatureNullToken, signatureYorah, "answer");
repo.Notes.Add(commit.Id, "I'm batman!\n", signatureNullToken, signatureYorah, "answer");
var note = repo.Notes[new ObjectId("5b5b025afb0b4c913b4c338a42934a3863bf3644")].FirstOrDefault(x => x.Namespace == "answer");

Assert.NotNull(note);
Expand All @@ -158,18 +158,18 @@ public void CanCompareTwoUniqueNotes()
{
var commit = repo.Lookup<Commit>("9fd738e8f7967c078dceed8190330fc8648ee56a");

var firstNote = repo.Notes.Create(commit.Id, "I'm batman!\n", signatureNullToken, signatureYorah, "batmobile");
var secondNote = repo.Notes.Create(commit.Id, "I'm batman!\n", signatureNullToken, signatureYorah, "batmobile");
var firstNote = repo.Notes.Add(commit.Id, "I'm batman!\n", signatureNullToken, signatureYorah, "batmobile");
var secondNote = repo.Notes.Add(commit.Id, "I'm batman!\n", signatureNullToken, signatureYorah, "batmobile");
Assert.Equal(firstNote, secondNote);

var firstNoteWithAnotherNamespace = repo.Notes.Create(commit.Id, "I'm batman!\n", signatureNullToken, signatureYorah, "batmobile2");
var firstNoteWithAnotherNamespace = repo.Notes.Add(commit.Id, "I'm batman!\n", signatureNullToken, signatureYorah, "batmobile2");
Assert.NotEqual(firstNote, firstNoteWithAnotherNamespace);

var firstNoteWithAnotherMessage = repo.Notes.Create(commit.Id, "I'm ironman!\n", signatureNullToken, signatureYorah, "batmobile");
var firstNoteWithAnotherMessage = repo.Notes.Add(commit.Id, "I'm ironman!\n", signatureNullToken, signatureYorah, "batmobile");
Assert.NotEqual(firstNote, firstNoteWithAnotherMessage);

var anotherCommit = repo.Lookup<Commit>("c47800c7266a2be04c571c04d5a6614691ea99bd");
var firstNoteOnAnotherCommit = repo.Notes.Create(anotherCommit.Id, "I'm batman!\n", signatureNullToken, signatureYorah, "batmobile");
var firstNoteOnAnotherCommit = repo.Notes.Add(anotherCommit.Id, "I'm batman!\n", signatureNullToken, signatureYorah, "batmobile");
Assert.NotEqual(firstNote, firstNoteOnAnotherCommit);
}
}
Expand All @@ -196,7 +196,7 @@ public void CanRemoveANoteFromAGitObject()

Assert.NotEmpty(notes);

repo.Notes.Delete(commit.Id, signatureNullToken, signatureYorah, repo.Notes.DefaultNamespace);
repo.Notes.Remove(commit.Id, signatureNullToken, signatureYorah, repo.Notes.DefaultNamespace);

Assert.Empty(notes);
}
Expand All @@ -221,7 +221,7 @@ public void RemovingANonExistingNoteDoesntThrow()
{
var commit = repo.Lookup<Commit>("5b5b025afb0b4c913b4c338a42934a3863bf3644");

repo.Notes.Delete(commit.Id, signatureNullToken, signatureYorah, "answer2");
repo.Notes.Remove(commit.Id, signatureNullToken, signatureYorah, "answer2");
}
}

Expand Down
Loading