tests/TestCommitFiltering.cs
/// <summary>
/// Discard all commits that don't contain the 'test.bin' text in their message. Rewrite author and committer of the commit left.
/// </summary>
Discard all commits that don't contain the 'test.bin' text in their message. Rewrite author and committer of the commit left.
Discard all commits that don ' t contain the ' test . bin ' text in their message . Rewrite author and committer of the commit left .
[Fact]
        public void DiscardAllCommitMessageExceptOne()
        {
            var test = InitializeTest();
            Assert.Equal(0, Program.Main("--commit-filter",
                @"commit.Discard = !commit.Message.Contains(""test.bin""); if (!commit.Discard) { commit.AuthorName=""NewAuthor""; commit.AuthorEmail = ""test@gmail.com""; commit.CommitterName =""NewCommitter""; commit.CommitterEmail = ""test2@gmail.com""; }",
                "--repo-dir", test.Path,
                "--branch", NewBranch
                ));
            var repo = test.Repo;
            var headNewMaster = AssertBranchRef(repo);
            var newCommits = GetCommits(repo, headNewMaster);
            Assert.Equal(1, newCommits.Count);
            var commitLeft = newCommits[0];
            Assert.Contains("test.bin", commitLeft.Message);
            Assert.Equal("NewAuthor", commitLeft.Author.Name);
            Assert.Equal("test@gmail.com", commitLeft.Author.Email);
            Assert.Equal("NewCommitter", commitLeft.Committer.Name);
            Assert.Equal("test2@gmail.com", commitLeft.Committer.Email);
            test.Dispose();
        }
[ Fact ] public void DiscardAllCommitMessageExceptOne ( ) { var test = InitializeTest ( ) ; Assert . Equal ( 0 , Program . Main ( " " , @"commit.Discard = !commit.Message.Contains(""test.bin""); if (!commit.Discard) { commit.AuthorName=""NewAuthor""; commit.AuthorEmail = ""test@gmail.com""; commit.CommitterName =""NewCommitter""; commit.CommitterEmail = ""test2@gmail.com""; }" , " " , test . Path , " " , NewBranch ) ) ; var repo = test . Repo ; var headNewMaster = AssertBranchRef ( repo ) ; var newCommits = GetCommits ( repo , headNewMaster ) ; Assert . Equal ( 1 , newCommits . Count ) ; var commitLeft = newCommits [ 0 ] ; Assert . Contains ( " " , commitLeft . Message ) ; Assert . Equal ( " " , commitLeft . Author . Name ) ; Assert . Equal ( " " , commitLeft . Author . Email ) ; Assert . Equal ( " " , commitLeft . Committer . Name ) ; Assert . Equal ( " " , commitLeft . Committer . Email ) ; test . Dispose ( ) ; }
Discard all commits that don't contain the 'test.bin' text in their message.
Discard all commits that don ' t contain the ' test . bin ' text in their message .
// Test directly the main program as we want to test also command line parameters // We should have only 1 commit // Check new field // Cleanup the test only if we succeed