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


C# GitIndex.Add方法代码示例

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


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

示例1: TestBoth

 public virtual void TestBoth()
 {
     GitIndex index = new GitIndex(db);
     Tree tree = new Tree(db);
     index.Add(trash, WriteTrashFile("a", "a"));
     tree.AddFile("b/b");
     index.Add(trash, WriteTrashFile("c", "c"));
     tree.AddFile("c");
     new IndexTreeWalker(index, tree, trash, new IndexTreeWalkerTest.TestIndexTreeVisitor
         (this)).Walk();
     NUnit.Framework.Assert.IsTrue(indexOnlyEntriesVisited.Contains("a"));
     NUnit.Framework.Assert.IsTrue(treeOnlyEntriesVisited.Contains("b/b"));
     NUnit.Framework.Assert.IsTrue(bothVisited.Contains("c"));
 }
开发者ID:charles-cai,项目名称:ngit,代码行数:14,代码来源:IndexTreeWalkerTest.cs

示例2: TestAdded

 public virtual void TestAdded()
 {
     GitIndex index = new GitIndex(db);
     WriteTrashFile("file1", "file1");
     WriteTrashFile("dir/subfile", "dir/subfile");
     Tree tree = new Tree(db);
     tree.SetId(InsertTree(tree));
     index.Add(trash, new FilePath(trash, "file1"));
     index.Add(trash, new FilePath(trash, "dir/subfile"));
     index.Write();
     FileTreeIterator iterator = new FileTreeIterator(db);
     IndexDiff diff = new IndexDiff(db, tree.GetId(), iterator);
     diff.Diff();
     NUnit.Framework.Assert.AreEqual(2, diff.GetAdded().Count);
     NUnit.Framework.Assert.IsTrue(diff.GetAdded().Contains("file1"));
     NUnit.Framework.Assert.IsTrue(diff.GetAdded().Contains("dir/subfile"));
     NUnit.Framework.Assert.AreEqual(0, diff.GetChanged().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetModified().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetRemoved().Count);
 }
开发者ID:ashmind,项目名称:ngit,代码行数:20,代码来源:IndexDiffTest.cs

示例3: TestCheckingOutWithConflicts

 public virtual void TestCheckingOutWithConflicts()
 {
     GitIndex index = new GitIndex(db);
     index.Add(trash, WriteTrashFile("bar", "bar"));
     index.Add(trash, WriteTrashFile("foo/bar/baz/qux", "foo/bar"));
     RecursiveDelete(new FilePath(trash, "bar"));
     RecursiveDelete(new FilePath(trash, "foo"));
     WriteTrashFile("bar/baz/qux/foo", "another nasty one");
     WriteTrashFile("foo", "troublesome little bugger");
     try
     {
         WorkDirCheckout workDirCheckout = new WorkDirCheckout(db, trash, index, index);
         workDirCheckout.Checkout();
         NUnit.Framework.Assert.Fail("Should have thrown exception");
     }
     catch (NGit.Errors.CheckoutConflictException)
     {
     }
     // all is well
     WorkDirCheckout workDirCheckout_1 = new WorkDirCheckout(db, trash, index, index);
     workDirCheckout_1.SetFailOnConflict(false);
     workDirCheckout_1.Checkout();
     NUnit.Framework.Assert.IsTrue(new FilePath(trash, "bar").IsFile());
     NUnit.Framework.Assert.IsTrue(new FilePath(trash, "foo/bar/baz/qux").IsFile());
     GitIndex index2 = new GitIndex(db);
     RecursiveDelete(new FilePath(trash, "bar"));
     RecursiveDelete(new FilePath(trash, "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"));
     workDirCheckout_1 = new WorkDirCheckout(db, trash, index2, index);
     workDirCheckout_1.SetFailOnConflict(false);
     workDirCheckout_1.Checkout();
     NUnit.Framework.Assert.IsTrue(new FilePath(trash, "bar").IsFile());
     NUnit.Framework.Assert.IsTrue(new FilePath(trash, "foo/bar/baz/qux").IsFile());
     NUnit.Framework.Assert.IsNotNull(index2.GetEntry("bar"));
     NUnit.Framework.Assert.IsNotNull(index2.GetEntry("foo/bar/baz/qux"));
     NUnit.Framework.Assert.IsNull(index2.GetEntry("bar/baz/qux/foo"));
     NUnit.Framework.Assert.IsNull(index2.GetEntry("foo"));
 }
开发者ID:charles-cai,项目名称:ngit,代码行数:40,代码来源:WorkDirCheckoutTest.cs

示例4: TestIndexOnlyOneLevel

 public virtual void TestIndexOnlyOneLevel()
 {
     GitIndex index = new GitIndex(db);
     Tree tree = new Tree(db);
     index.Add(trash, WriteTrashFile("foo", "foo"));
     index.Add(trash, WriteTrashFile("bar", "bar"));
     new IndexTreeWalker(index, tree, trash, new IndexTreeWalkerTest.TestIndexTreeVisitor
         (this)).Walk();
     NUnit.Framework.Assert.IsTrue(indexOnlyEntriesVisited[0].Equals("bar"));
     NUnit.Framework.Assert.IsTrue(indexOnlyEntriesVisited[1].Equals("foo"));
 }
开发者ID:charles-cai,项目名称:ngit,代码行数:11,代码来源:IndexTreeWalkerTest.cs

示例5: TestLeavingTree

 public virtual void TestLeavingTree()
 {
     GitIndex 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, new _AbstractIndexTreeVisitor_144
         ()).Walk();
 }
开发者ID:charles-cai,项目名称:ngit,代码行数:8,代码来源:IndexTreeWalkerTest.cs

示例6: TestIndexOnlySubDirs

 public virtual void TestIndexOnlySubDirs()
 {
     GitIndex index = new GitIndex(db);
     Tree tree = new Tree(db);
     index.Add(trash, WriteTrashFile("foo/bar/baz", "foobar"));
     index.Add(trash, WriteTrashFile("asdf", "asdf"));
     new IndexTreeWalker(index, tree, trash, new IndexTreeWalkerTest.TestIndexTreeVisitor
         (this)).Walk();
     NUnit.Framework.Assert.AreEqual("asdf", indexOnlyEntriesVisited[0]);
     NUnit.Framework.Assert.AreEqual("foo/bar/baz", indexOnlyEntriesVisited[1]);
 }
开发者ID:charles-cai,项目名称:ngit,代码行数:11,代码来源:IndexTreeWalkerTest.cs

示例7: TestFindingConflicts

 public virtual void TestFindingConflicts()
 {
     GitIndex index = new GitIndex(db);
     index.Add(trash, WriteTrashFile("bar", "bar"));
     index.Add(trash, WriteTrashFile("foo/bar/baz/qux", "foo/bar"));
     RecursiveDelete(new FilePath(trash, "bar"));
     RecursiveDelete(new FilePath(trash, "foo"));
     WriteTrashFile("bar/baz/qux/foo", "another nasty one");
     WriteTrashFile("foo", "troublesome little bugger");
     WorkDirCheckout workDirCheckout = new WorkDirCheckout(db, trash, index, index);
     workDirCheckout.PrescanOneTree();
     IList<string> conflictingEntries = workDirCheckout.GetConflicts();
     IList<string> removedEntries = workDirCheckout.GetRemoved();
     NUnit.Framework.Assert.AreEqual("bar/baz/qux/foo", conflictingEntries[0]);
     NUnit.Framework.Assert.AreEqual("foo", conflictingEntries[1]);
     GitIndex index2 = new GitIndex(db);
     RecursiveDelete(new FilePath(trash, "bar"));
     RecursiveDelete(new FilePath(trash, "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.GetConflicts();
     removedEntries = workDirCheckout.GetRemoved();
     NUnit.Framework.Assert.IsTrue(conflictingEntries.IsEmpty());
     NUnit.Framework.Assert.IsTrue(removedEntries.Contains("bar/baz/qux/foo"));
     NUnit.Framework.Assert.IsTrue(removedEntries.Contains("foo"));
 }
开发者ID:charles-cai,项目名称:ngit,代码行数:28,代码来源:WorkDirCheckoutTest.cs

示例8: TestUnchangedSimple

 public virtual void TestUnchangedSimple()
 {
     GitIndex index = new GitIndex(db);
     index.Add(trash, WriteTrashFile("a.b", "a.b"));
     index.Add(trash, WriteTrashFile("a.c", "a.c"));
     index.Add(trash, WriteTrashFile("a=c", "a=c"));
     index.Add(trash, WriteTrashFile("a=d", "a=d"));
     index.Write();
     Tree tree = new Tree(db);
     // got the hash id'd from the data using echo -n a.b|git hash-object -t blob --stdin
     tree.AddFile("a.b").SetId(ObjectId.FromString("f6f28df96c2b40c951164286e08be7c38ec74851"
         ));
     tree.AddFile("a.c").SetId(ObjectId.FromString("6bc0e647512d2a0bef4f26111e484dc87df7f5ca"
         ));
     tree.AddFile("a=c").SetId(ObjectId.FromString("06022365ddbd7fb126761319633bf73517770714"
         ));
     tree.AddFile("a=d").SetId(ObjectId.FromString("fa6414df3da87840700e9eeb7fc261dd77ccd5c2"
         ));
     tree.SetId(InsertTree(tree));
     FileTreeIterator iterator = new FileTreeIterator(db);
     IndexDiff diff = new IndexDiff(db, tree.GetId(), iterator);
     diff.Diff();
     NUnit.Framework.Assert.AreEqual(0, diff.GetChanged().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetAdded().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetRemoved().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetMissing().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetModified().Count);
 }
开发者ID:ashmind,项目名称:ngit,代码行数:28,代码来源:IndexDiffTest.cs

示例9: TestUnchangedComplex

 public virtual void TestUnchangedComplex()
 {
     GitIndex index = new GitIndex(db);
     index.Add(trash, WriteTrashFile("a.b", "a.b"));
     index.Add(trash, WriteTrashFile("a.c", "a.c"));
     index.Add(trash, WriteTrashFile("a/b.b/b", "a/b.b/b"));
     index.Add(trash, WriteTrashFile("a/b", "a/b"));
     index.Add(trash, WriteTrashFile("a/c", "a/c"));
     index.Add(trash, WriteTrashFile("a=c", "a=c"));
     index.Add(trash, WriteTrashFile("a=d", "a=d"));
     index.Write();
     Tree tree = new Tree(db);
     // got the hash id'd from the data using echo -n a.b|git hash-object -t blob --stdin
     tree.AddFile("a.b").SetId(ObjectId.FromString("f6f28df96c2b40c951164286e08be7c38ec74851"
         ));
     tree.AddFile("a.c").SetId(ObjectId.FromString("6bc0e647512d2a0bef4f26111e484dc87df7f5ca"
         ));
     tree.AddFile("a/b.b/b").SetId(ObjectId.FromString("8d840bd4e2f3a48ff417c8e927d94996849933fd"
         ));
     tree.AddFile("a/b").SetId(ObjectId.FromString("db89c972fc57862eae378f45b74aca228037d415"
         ));
     tree.AddFile("a/c").SetId(ObjectId.FromString("52ad142a008aeb39694bafff8e8f1be75ed7f007"
         ));
     tree.AddFile("a=c").SetId(ObjectId.FromString("06022365ddbd7fb126761319633bf73517770714"
         ));
     tree.AddFile("a=d").SetId(ObjectId.FromString("fa6414df3da87840700e9eeb7fc261dd77ccd5c2"
         ));
     Tree tree3 = (Tree)tree.FindTreeMember("a/b.b");
     tree3.SetId(InsertTree(tree3));
     Tree tree2 = (Tree)tree.FindTreeMember("a");
     tree2.SetId(InsertTree(tree2));
     tree.SetId(InsertTree(tree));
     FileTreeIterator iterator = new FileTreeIterator(db);
     IndexDiff diff = new IndexDiff(db, tree.GetId(), iterator);
     diff.Diff();
     NUnit.Framework.Assert.AreEqual(0, diff.GetChanged().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetAdded().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetRemoved().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetMissing().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetModified().Count);
 }
开发者ID:ashmind,项目名称:ngit,代码行数:41,代码来源:IndexDiffTest.cs

示例10: TestModified

 public virtual void TestModified()
 {
     GitIndex index = new GitIndex(db);
     index.Add(trash, WriteTrashFile("file2", "file2"));
     index.Add(trash, WriteTrashFile("dir/file3", "dir/file3"));
     index.Write();
     WriteTrashFile("dir/file3", "changed");
     Tree tree = new Tree(db);
     tree.AddFile("file2").SetId(ObjectId.FromString("0123456789012345678901234567890123456789"
         ));
     tree.AddFile("dir/file3").SetId(ObjectId.FromString("0123456789012345678901234567890123456789"
         ));
     NUnit.Framework.Assert.AreEqual(2, tree.MemberCount());
     Tree tree2 = (Tree)tree.FindTreeMember("dir");
     tree2.SetId(InsertTree(tree2));
     tree.SetId(InsertTree(tree));
     FileTreeIterator iterator = new FileTreeIterator(db);
     IndexDiff diff = new IndexDiff(db, tree.GetId(), iterator);
     diff.Diff();
     NUnit.Framework.Assert.AreEqual(2, diff.GetChanged().Count);
     NUnit.Framework.Assert.IsTrue(diff.GetChanged().Contains("file2"));
     NUnit.Framework.Assert.IsTrue(diff.GetChanged().Contains("dir/file3"));
     NUnit.Framework.Assert.AreEqual(1, diff.GetModified().Count);
     NUnit.Framework.Assert.IsTrue(diff.GetModified().Contains("dir/file3"));
     NUnit.Framework.Assert.AreEqual(0, diff.GetAdded().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetRemoved().Count);
     NUnit.Framework.Assert.AreEqual(0, diff.GetMissing().Count);
 }
开发者ID:ashmind,项目名称:ngit,代码行数:28,代码来源:IndexDiffTest.cs

示例11: BuildIndex

		/// <exception cref="System.IO.IOException"></exception>
		private void BuildIndex(Dictionary<string, string> indexEntries)
		{
			GitIndex index = new GitIndex(db);
			if (indexEntries != null)
			{
				foreach (KeyValuePair<string, string> e in indexEntries.EntrySet())
				{
					index.Add(trash, WriteTrashFile(e.Key, e.Value)).ForceRecheck();
				}
			}
			index.Write();
			db.GetIndex().Read();
		}
开发者ID:shoff,项目名称:ngit,代码行数:14,代码来源:ReadTreeTest.cs


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