예제 #1
0
파일: IndexDiffTest.cs 프로젝트: shoff/ngit
        public virtual void TestAssumeUnchanged()
        {
            Git    git  = new Git(db);
            string path = "file";

            WriteTrashFile(path, "content");
            git.Add().AddFilepattern(path).Call();
            string path2 = "file2";

            WriteTrashFile(path2, "content");
            git.Add().AddFilepattern(path2).Call();
            git.Commit().SetMessage("commit").Call();
            AssumeUnchanged(path2);
            WriteTrashFile(path, "more content");
            WriteTrashFile(path2, "more content");
            FileTreeIterator iterator = new FileTreeIterator(db);
            IndexDiff        diff     = new IndexDiff(db, Constants.HEAD, iterator);

            diff.Diff();
            NUnit.Framework.Assert.AreEqual(1, diff.GetAssumeUnchanged().Count);
            NUnit.Framework.Assert.AreEqual(1, diff.GetModified().Count);
            NUnit.Framework.Assert.AreEqual(0, diff.GetChanged().Count);
            NUnit.Framework.Assert.IsTrue(diff.GetAssumeUnchanged().Contains("file2"));
            NUnit.Framework.Assert.IsTrue(diff.GetModified().Contains("file"));
            git.Add().AddFilepattern(".").Call();
            iterator = new FileTreeIterator(db);
            diff     = new IndexDiff(db, Constants.HEAD, iterator);
            diff.Diff();
            NUnit.Framework.Assert.AreEqual(1, diff.GetAssumeUnchanged().Count);
            NUnit.Framework.Assert.AreEqual(0, diff.GetModified().Count);
            NUnit.Framework.Assert.AreEqual(1, diff.GetChanged().Count);
            NUnit.Framework.Assert.IsTrue(diff.GetAssumeUnchanged().Contains("file2"));
            NUnit.Framework.Assert.IsTrue(diff.GetChanged().Contains("file"));
        }
예제 #2
0
 public virtual void TestAssumeUnchanged()
 {
     Git git = new Git(db);
     string path = "file";
     WriteTrashFile(path, "content");
     git.Add().AddFilepattern(path).Call();
     string path2 = "file2";
     WriteTrashFile(path2, "content");
     git.Add().AddFilepattern(path2).Call();
     git.Commit().SetMessage("commit").Call();
     AssumeUnchanged(path2);
     WriteTrashFile(path, "more content");
     WriteTrashFile(path2, "more content");
     FileTreeIterator iterator = new FileTreeIterator(db);
     IndexDiff diff = new IndexDiff(db, Constants.HEAD, iterator);
     diff.Diff();
     NUnit.Framework.Assert.AreEqual(1, diff.GetAssumeUnchanged().Count);
     NUnit.Framework.Assert.AreEqual(1, diff.GetModified().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetChanged().Count);
     NUnit.Framework.Assert.IsTrue(diff.GetAssumeUnchanged().Contains("file2"));
     NUnit.Framework.Assert.IsTrue(diff.GetModified().Contains("file"));
     git.Add().AddFilepattern(".").Call();
     iterator = new FileTreeIterator(db);
     diff = new IndexDiff(db, Constants.HEAD, iterator);
     diff.Diff();
     NUnit.Framework.Assert.AreEqual(1, diff.GetAssumeUnchanged().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetModified().Count);
     NUnit.Framework.Assert.AreEqual(1, diff.GetChanged().Count);
     NUnit.Framework.Assert.IsTrue(diff.GetAssumeUnchanged().Contains("file2"));
     NUnit.Framework.Assert.IsTrue(diff.GetChanged().Contains("file"));
     NUnit.Framework.CollectionAssert.AreEquivalent(Sharpen.Collections<string>.EMPTY_SET, diff.GetUntrackedFolders
         ());
 }
예제 #3
0
        protected void RaiseNotifyFromDiff(Repository repository)
        {
            if (repository == null)
                throw new ArgumentNullException("repository");
            var workingTreeIt = new FileTreeIterator(repository);
            var diff = new IndexDiff(repository, Constants.HEAD, workingTreeIt);

            diff.Diff();

            RaiseNotifyFromDiff(repository, diff.GetAdded(), GitNotifyAction.UpdateAdd);
            RaiseNotifyFromDiff(repository, diff.GetAssumeUnchanged(), GitNotifyAction.UpdateUpdate);
            RaiseNotifyFromDiff(repository, diff.GetChanged(), GitNotifyAction.UpdateUpdate);
            RaiseNotifyFromDiff(repository, diff.GetConflicting(), GitNotifyAction.UpdateUpdate);
            RaiseNotifyFromDiff(repository, diff.GetMissing(), GitNotifyAction.UpdateDeleted);
            RaiseNotifyFromDiff(repository, diff.GetModified(), GitNotifyAction.UpdateUpdate);
            RaiseNotifyFromDiff(repository, diff.GetRemoved(), GitNotifyAction.UpdateDeleted);
            RaiseNotifyFromDiff(repository, diff.GetUntracked(), GitNotifyAction.UpdateUpdate);
        }