diff options
author | Keith Dahlby <dahlbyk@gmail.com> | 2013-11-11 08:10:01 +0400 |
---|---|---|
committer | Keith Dahlby <dahlbyk@gmail.com> | 2013-11-11 18:19:20 +0400 |
commit | c890e615e5a8c74a28f41e61de6e15a491eb0378 (patch) | |
tree | 96c8e60f9b19e51d1ecf1ad3d4f6483e8516c674 /LibGit2Sharp.Tests | |
parent | d6079d4a17d0fcd2150a681f197210752241447d (diff) |
Add rewrite test that injects existing TreeEntry
Diffstat (limited to 'LibGit2Sharp.Tests')
-rw-r--r-- | LibGit2Sharp.Tests/FilterBranchFixture.cs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/LibGit2Sharp.Tests/FilterBranchFixture.cs b/LibGit2Sharp.Tests/FilterBranchFixture.cs index 96c583f7..efed5c0b 100644 --- a/LibGit2Sharp.Tests/FilterBranchFixture.cs +++ b/LibGit2Sharp.Tests/FilterBranchFixture.cs @@ -213,6 +213,34 @@ namespace LibGit2Sharp.Tests Assert.True(repo.Head.Commits.All(c => c["README"] == null)); } + [Fact] + public void CanRewriteTreesByInjectingTreeEntry() + { + var commits = repo.Commits.QueryBy(new CommitFilter { Since = repo.Branches }).ToArray(); + + var currentReadme = repo.Head["README"]; + + repo.Refs.RewriteHistory(new RewriteHistoryOptions + { + OnError = OnError, + OnSucceeding = OnSucceeding, + CommitTreeRewriter = + c => c["README"] == null + ? TreeDefinition.From(c) + : TreeDefinition.From(c) + .Add("README", currentReadme), + }, commits); + + AssertSucceedingButNotError(); + + Assert.Equal(new Commit[0], + repo.Commits + .QueryBy(new CommitFilter {Since = repo.Branches}) + .Where(c => c["README"] != null + && c["README"].Target.Id != currentReadme.Target.Id) + .ToArray()); + } + // git log --graph --oneline --name-status --decorate // // * 4c062a6 (HEAD, master) directory was added |