当前位置: 首页>>代码示例>>C#>>正文


C# GitIndex.add方法代码示例

本文整理汇总了C#中GitIndex.add方法的典型用法代码示例。如果您正苦于以下问题:C# GitIndex.add方法的具体用法?C# GitIndex.add怎么用?C# GitIndex.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GitIndex的用法示例。


在下文中一共展示了GitIndex.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: testModified

        public void testModified()
        {
            var index = new GitIndex(db);

            index.add(trash, writeTrashFile("file2", "file2"));
            index.add(trash, writeTrashFile("dir/file3", "dir/file3"));

            writeTrashFile("dir/file3", "changed");

            var t = new Tree(db);
            t.AddFile("file2").Id = ObjectId.FromString("0123456789012345678901234567890123456789");
            t.AddFile("dir/file3").Id = ObjectId.FromString("0123456789012345678901234567890123456789");
            Assert.AreEqual(2, t.MemberCount);

            var tree2 = (Tree) t.findTreeMember("dir");
            tree2.Id = new ObjectWriter(db).WriteTree(tree2);
            t.Id = new ObjectWriter(db).WriteTree(t);
            var diff = new IndexDiff(t, index);
            diff.Diff();
            Assert.AreEqual(2, diff.Changed.Count);
            Assert.IsTrue(diff.Changed.Contains("file2"));
            Assert.IsTrue(diff.Changed.Contains("dir/file3"));
            Assert.AreEqual(1, diff.Modified.Count);
            Assert.IsTrue(diff.Modified.Contains("dir/file3"));
            Assert.AreEqual(0, diff.Added.Count);
            Assert.AreEqual(0, diff.Removed.Count);
            Assert.AreEqual(0, diff.Missing.Count);
        }
开发者ID:georgeck,项目名称:GitSharp,代码行数:28,代码来源:IndexDiffTest.cs

示例2: testAdded

        public void testAdded()
        {
            var index = new GitIndex(db);
            writeTrashFile("file1", "file1");
            writeTrashFile("dir/subfile", "dir/subfile");
            var tree = new Tree(db);

            index.add(trash, new FileInfo(Path.Combine(trash.FullName, "file1")));
            index.add(trash, new FileInfo(Path.Combine(trash.FullName, "dir/subfile")));
            var diff = new IndexDiff(tree, index);
            diff.Diff();

            Assert.AreEqual(2, diff.Added.Count);
            Assert.IsTrue(diff.Added.Contains("file1"));
            Assert.IsTrue(diff.Added.Contains("dir/subfile"));
            Assert.AreEqual(0, diff.Changed.Count);
            Assert.AreEqual(0, diff.Modified.Count);
            Assert.AreEqual(0, diff.Removed.Count);
        }
开发者ID:georgeck,项目名称:GitSharp,代码行数:19,代码来源:IndexDiffTest.cs

示例3: testCheckingOutWithConflicts

        public void testCheckingOutWithConflicts()
        {
            var index = new GitIndex(db);
            index.add(trash, writeTrashFile("bar", "bar"));
            index.add(trash, writeTrashFile("foo/bar/baz/qux", "foo/bar"));
            recursiveDelete(new FileInfo(Path.Combine(trash.FullName, "bar")));
            recursiveDelete(new DirectoryInfo(Path.Combine(trash.FullName, "foo")));
            writeTrashFile("bar/baz/qux/foo", "another nasty one");
            writeTrashFile("foo", "troublesome little bugger");
            
            var workDirCheckout1 = new WorkDirCheckout(db, trash, index, index);

            AssertHelper.Throws<CheckoutConflictException>(workDirCheckout1.checkout);


            var workDirCheckout2 = new WorkDirCheckout(db, trash, index, index) { FailOnConflict = false };
            workDirCheckout2.checkout();

            Assert.IsTrue(new FileInfo(Path.Combine(trash.FullName, "bar")).IsFile());
            Assert.IsTrue(new FileInfo(Path.Combine(trash.FullName, "foo/bar/baz/qux")).IsFile());

            var index2 = new GitIndex(db);
            recursiveDelete(new FileInfo(Path.Combine(trash.FullName, "bar")));
            recursiveDelete(new DirectoryInfo(Path.Combine(trash.FullName, "foo")));
            index2.add(trash, writeTrashFile("bar/baz/qux/foo", "bar"));
            writeTrashFile("bar/baz/qux/bar", "evil? I thought it said WEEVIL!");
            index2.add(trash, writeTrashFile("foo", "lalala"));

            workDirCheckout2 = new WorkDirCheckout(db, trash, index2, index) { FailOnConflict = false };
            workDirCheckout2.checkout();

            Assert.IsTrue(new FileInfo(Path.Combine(trash.FullName, "bar")).IsFile());
            Assert.IsTrue(new FileInfo(Path.Combine(trash.FullName, "foo/bar/baz/qux")).IsFile());
            Assert.IsNotNull(index2.GetEntry("bar"));
            Assert.IsNotNull(index2.GetEntry("foo/bar/baz/qux"));
            Assert.IsNull(index2.GetEntry("bar/baz/qux/foo"));
            Assert.IsNull(index2.GetEntry("foo"));
        }
开发者ID:dev218,项目名称:GitSharp,代码行数:38,代码来源:WorkDirCheckoutTest.cs

示例4: ShouldSupportNotModifiedExtensionlessFilesWithoutContentChecking

		public void ShouldSupportNotModifiedExtensionlessFilesWithoutContentChecking()
		{
			var index = new GitIndex(db);

			writeTrashFile("extensionless-file", "contents");

			var file = new FileInfo(Path.Combine(trash.FullName, "extensionless-file"));

			index.add(trash, file);

			var entry = index.GetEntry("extensionless-file");

			Assert.IsFalse(entry.IsModified(trash));
		}
开发者ID:dev218,项目名称:GitSharp,代码行数:14,代码来源:IndexModifiedTests.cs

示例5: testAdded2

        public void testAdded2()
        {
            var index = new GitIndex(db);
            writeTrashFile("test/für henon.txt", "Weißebier");
            var tree = new Core.Tree(db);

            index.add(trash, new FileInfo(Path.Combine(trash.FullName, "test/für henon.txt")));
            var diff = new IndexDiff(tree, index);
            diff.Diff();

            Assert.AreEqual(1, diff.Added.Count);
            Assert.IsTrue(diff.Added.Contains("test/für henon.txt"));
            Assert.AreEqual(0, diff.Changed.Count);
            Assert.AreEqual(0, diff.Modified.Count);
            Assert.AreEqual(0, diff.Removed.Count);
        }
开发者ID:jagregory,项目名称:GitSharp,代码行数:16,代码来源:IndexDiffTest.cs

示例6: ShouldAllowComparingOfAlreadyOpenedFile

		public void ShouldAllowComparingOfAlreadyOpenedFile()
		{
			var index = new GitIndex(db);
			var file = writeTrashFile("extensionless-file", "contents");

			index.add(trash, file);

			var entry = index.GetEntry("extensionless-file");

			// [henon] failed on my windows box (originally only observed on mono/unix) when executed in resharper or with nunit without waiting a second!
			// as the timing is not the point of the test here let's wait a sec anyway.
			Thread.Sleep(TimeSpan.FromSeconds(1));

			// replace contents of file (with same size so it passes the size check)
			using (var writer = file.CreateText())
				writer.Write("stnetnoc");

			// opening the file for reading shoudn't block us from checking the contents
			using (file.OpenRead())
				Assert.IsTrue(entry.IsModified(trash, true));
		}
开发者ID:dev218,项目名称:GitSharp,代码行数:21,代码来源:IndexModifiedTests.cs

示例7: ShouldAllowComparingOfAlreadyOpenedFile

        public void ShouldAllowComparingOfAlreadyOpenedFile()
        {
            var index = new GitIndex(db);
            var file = writeTrashFile("extensionless-file", "contents");

            index.add(trash, file);

            var entry = index.GetEntry("extensionless-file");

            if (AssertHelper.IsRunningOnMono())
            {
                // File timestamps on Unix based systems are only precise to the second
                Thread.Sleep(TimeSpan.FromSeconds(1));
            }

            // replace contents of file (with same size so it passes the size check)
            using (var writer = file.CreateText())
                writer.Write("stnetnoc");

            // opening the file for reading shoudn't block us from checking the contents
            using (file.OpenRead())
                Assert.IsTrue(entry.IsModified(trash, true));
        }
开发者ID:jagregory,项目名称:GitSharp,代码行数:23,代码来源:IndexModifiedTests.cs

示例8: testCheckout

        public void testCheckout()
        {
            // Prepare tree, remote it and checkout
            var index = new GitIndex(db);
            FileInfo aslashb = writeTrashFile("a/b", "data:a/b");
            FileInfo acolonb = writeTrashFile("[email protected]", "data:a:b");
            FileInfo adotb = writeTrashFile("a.b", "data:a.b");
            index.add(trash, aslashb);
            index.add(trash, acolonb);
            index.add(trash, adotb);
            index.write();
            index.writeTree();
            Delete(aslashb);
            Delete(acolonb);
            Delete(adotb);
            Delete(Directory.GetParent(aslashb.FullName));

            var index2 = new GitIndex(db);
            Assert.AreEqual(0, index2.Members.Count);

            index2.ReadTree(db.MapTree(ObjectId.FromString("0036d433dc4f10ec47b61abc3ec5033c78d34f84")));

            index2.checkout(trash);
            Assert.AreEqual("data:a/b", Content(aslashb));
            Assert.AreEqual("data:a:b", Content(acolonb));
            Assert.AreEqual("data:a.b", Content(adotb));

            if (CanRunGitStatus)
            {
                Assert.AreEqual(0, System(trash, "git status"));
            }
        }
开发者ID:jagregory,项目名称:GitSharp,代码行数:32,代码来源:T0007_Index.cs

示例9: testFindingConflicts

        public void testFindingConflicts()
        {
            var index = new GitIndex(db);
            index.add(trash, writeTrashFile("bar", "bar"));
            index.add(trash, writeTrashFile("foo/bar/baz/qux", "foo/bar"));
            recursiveDelete(new FileInfo(Path.Combine(trash.FullName, "bar")));
            recursiveDelete(new DirectoryInfo(Path.Combine(trash.FullName, "foo")));
            writeTrashFile("bar/baz/qux/foo", "another nasty one");
            writeTrashFile("foo", "troublesome little bugger");

            var workDirCheckout = new WorkDirCheckout(db, trash, index, index);
            workDirCheckout.PrescanOneTree();
            List<string> conflictingEntries = workDirCheckout.Conflicts;
            Assert.AreEqual("bar/baz/qux/foo", conflictingEntries[0]);
            Assert.AreEqual("foo", conflictingEntries[1]);

            var index2 = new GitIndex(db);
            recursiveDelete(new DirectoryInfo(Path.Combine(trash.FullName, "bar")));
            recursiveDelete(new DirectoryInfo(Path.Combine(trash.FullName, "foo")));

            index2.add(trash, writeTrashFile("bar/baz/qux/foo", "bar"));
            index2.add(trash, writeTrashFile("foo", "lalala"));

            workDirCheckout = new WorkDirCheckout(db, trash, index2, index);
            workDirCheckout.PrescanOneTree();

            conflictingEntries = workDirCheckout.Conflicts;
            List<string> removedEntries = workDirCheckout.Removed;
            Assert.IsTrue(conflictingEntries.Count == 0);
            Assert.IsTrue(removedEntries.Contains("bar/baz/qux/foo"));
            Assert.IsTrue(removedEntries.Contains("foo"));
        }
开发者ID:jagregory,项目名称:GitSharp,代码行数:32,代码来源:WorkDirCheckoutTest.cs

示例10: BuildIndex

 private GitIndex BuildIndex(Dictionary<string, string> indexEntries)
 {
     var index = new GitIndex(db);
     if (indexEntries != null)
     {
         foreach (var pair in indexEntries)
         {
             index.add(trash, writeTrashFile(pair.Key, pair.Value)).forceRecheck();
         }
     }
     return index;
 }
开发者ID:jagregory,项目名称:GitSharp,代码行数:12,代码来源:ReadTreeTest.cs

示例11: testDirectoryFileSimple

        public void testDirectoryFileSimple()
        {
            _theIndex = new GitIndex(db);
            _theIndex.add(trash, writeTrashFile("DF", "DF"));
            Core.Tree head = db.MapTree(_theIndex.writeTree());
            recursiveDelete(new DirectoryInfo(Path.Combine(trash.FullName, "DF")));

            _theIndex = new GitIndex(db);
            _theIndex.add(trash, writeTrashFile("DF/DF", "DF/DF"));
            Core.Tree merge = db.MapTree(_theIndex.writeTree());
            _theIndex = new GitIndex(db);
            recursiveDelete(new DirectoryInfo(Path.Combine(trash.FullName, "DF")));

            _theIndex.add(trash, writeTrashFile("DF", "DF"));
            _theReadTree = new WorkDirCheckout(db, trash, head, _theIndex, merge);
            _theReadTree.PrescanTwoTrees();
            Assert.IsTrue(_theReadTree.Removed.Contains("DF"));
            Assert.IsTrue(_theReadTree.Updated.ContainsKey("DF/DF"));
            recursiveDelete(new DirectoryInfo(Path.Combine(trash.FullName, "DF")));

            _theIndex = new GitIndex(db);
            _theIndex.add(trash, writeTrashFile("DF/DF", "DF/DF"));
            _theReadTree = new WorkDirCheckout(db, trash, merge, _theIndex, head);
            _theReadTree.PrescanTwoTrees();
            Assert.IsTrue(_theReadTree.Removed.Contains("DF/DF"));
            Assert.IsTrue(_theReadTree.Updated.ContainsKey("DF"));
        }
开发者ID:jagregory,项目名称:GitSharp,代码行数:27,代码来源:ReadTreeTest.cs

示例12: testLeavingTree

        public void testLeavingTree()
        {
            var index = new GitIndex(db);
            index.add(trash, writeTrashFile("foo/bar", "foo/bar"));
            index.add(trash, writeTrashFile("foobar", "foobar"));

            new IndexTreeWalker(index, db.MapTree(index.writeTree()), trash, TestTreeOnlyOneLevelTreeVisitor).Walk();
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:8,代码来源:IndexTreeWalkerTest.cs

示例13: testIndexOnlySubDirs

        public void testIndexOnlySubDirs()
        {
            var index = new GitIndex(db);
            var mainTree = new Tree(db);

            index.add(trash, writeTrashFile("foo/bar/baz", "foobar"));
            index.add(trash, writeTrashFile("asdf", "asdf"));
            new IndexTreeWalker(index, mainTree, trash, TestIndexTreeVisitor).Walk();

            Assert.AreEqual("asdf", IndexOnlyEntriesVisited[0]);
            Assert.AreEqual("foo/bar/baz", IndexOnlyEntriesVisited[1]);
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:12,代码来源:IndexTreeWalkerTest.cs

示例14: testUpdateSimpleSortTestIndex

        public void testUpdateSimpleSortTestIndex()
        {
            var index = new GitIndex(db);
            writeTrashFile("a/b", "data:a/b");
            writeTrashFile("[email protected]", "data:a:b");
            writeTrashFile("a.b", "data:a.b");
            index.add(trash, new FileInfo(Path.Combine(trash.FullName, "a/b")));
            index.add(trash, new FileInfo(Path.Combine(trash.FullName, "[email protected]")));
            index.add(trash, new FileInfo(Path.Combine(trash.FullName, "a.b")));
            writeTrashFile("a/b", "data:a/b modified");
            index.add(trash, new FileInfo(Path.Combine(trash.FullName, "a/b")));
            index.write();

            if (CanRunGitStatus)
            {
                Assert.AreEqual(0, System(trash, "git status"));
            }
        }
开发者ID:jagregory,项目名称:GitSharp,代码行数:18,代码来源:T0007_Index.cs

示例15: testReadTree

        public void testReadTree()
        {
            // Prepare tree
            var index = new GitIndex(db);
            writeTrashFile("a/b", "data:a/b");
            writeTrashFile("a:b", "data:a:b");
            writeTrashFile("a.b", "data:a.b");
            index.add(trash, new FileInfo(Path.Combine(trash.FullName, "a/b")));
            index.add(trash, new FileInfo(Path.Combine(trash.FullName, "a:b")));
            index.add(trash, new FileInfo(Path.Combine(trash.FullName, "a.b")));
            index.write();

            ObjectId id = index.writeTree();
            Console.WriteLine("wrote id " + id);
            Assert.AreEqual("c696abc3ab8e091c665f49d00eb8919690b3aec3", id.Name);
            var index2 = new GitIndex(db);

            index2.ReadTree(db.MapTree(ObjectId.FromString("c696abc3ab8e091c665f49d00eb8919690b3aec3")));
            GitIndex.Entry[] members = index2.Members;
            Assert.AreEqual(3, members.Length);
            Assert.AreEqual("a.b", members[0].Name);
            Assert.AreEqual("a/b", members[1].Name);
            Assert.AreEqual("a:b", members[2].Name);
            Assert.AreEqual(3, members.Length);

            var indexr = new GitIndex(db);
            indexr.Read();
            GitIndex.Entry[] membersr = indexr.Members;
            Assert.AreEqual(3, membersr.Length);
            Assert.AreEqual("a.b", membersr[0].Name);
            Assert.AreEqual("a/b", membersr[1].Name);
            Assert.AreEqual("a:b", membersr[2].Name);
            Assert.AreEqual(3, membersr.Length);

            if (CanRunGitStatus)
            {
                Assert.AreEqual(0, System(trash, "git status"));
            }
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:39,代码来源:IndexTests.cs


注:本文中的GitIndex.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。