本文整理汇总了C#中ObjectWriter.WriteTree方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectWriter.WriteTree方法的具体用法?C# ObjectWriter.WriteTree怎么用?C# ObjectWriter.WriteTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectWriter
的用法示例。
在下文中一共展示了ObjectWriter.WriteTree方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: testMissingSubtree_DetectFileAdded_FileModified
public void testMissingSubtree_DetectFileAdded_FileModified()
{
var ow = new ObjectWriter(db);
ObjectId aFileId = ow.WriteBlob(Constants.CHARSET.GetBytes("a"));
ObjectId bFileId = ow.WriteBlob(Constants.CHARSET.GetBytes("b"));
ObjectId cFileId1 = ow.WriteBlob(Constants.CHARSET.GetBytes("c-1"));
ObjectId cFileId2 = ow.WriteBlob(Constants.CHARSET.GetBytes("c-2"));
// Create sub-a/empty, sub-c/empty = hello.
Func<ObjectId> oldTree = () =>
{
var root = new Tree(db);
Tree subA = root.AddTree("sub-a");
subA.AddFile("empty").Id = aFileId;
subA.Id = ow.WriteTree(subA);
Tree subC = root.AddTree("sub-c");
subC.AddFile("empty").Id = cFileId1;
subC.Id = ow.WriteTree(subC);
return ow.WriteTree(root);
};
// Create sub-a/empty, sub-b/empty, sub-c/empty.
Func<ObjectId> newTree = () =>
{
var root = new Tree(db);
Tree subA = root.AddTree("sub-a");
subA.AddFile("empty").Id = aFileId;
subA.Id = ow.WriteTree(subA);
Tree subB = root.AddTree("sub-b");
subB.AddFile("empty").Id = bFileId;
subB.Id = ow.WriteTree(subB);
Tree subC = root.AddTree("sub-c");
subC.AddFile("empty").Id = cFileId2;
subC.Id = ow.WriteTree(subC);
return ow.WriteTree(root);
};
var tw = new GitSharp.TreeWalk.TreeWalk(db);
tw.reset(new[] { oldTree.Invoke(), newTree.Invoke() });
tw.Recursive = true;
tw.setFilter(TreeFilter.ANY_DIFF);
Assert.IsTrue(tw.next());
Assert.AreEqual("sub-b/empty", tw.getPathString());
Assert.AreEqual(FileMode.Missing, tw.getFileMode(0));
Assert.AreEqual(FileMode.RegularFile, tw.getFileMode(1));
Assert.AreEqual(ObjectId.ZeroId, tw.getObjectId(0));
Assert.AreEqual(bFileId, tw.getObjectId(1));
Assert.IsTrue(tw.next());
Assert.AreEqual("sub-c/empty", tw.getPathString());
Assert.AreEqual(FileMode.RegularFile, tw.getFileMode(0));
Assert.AreEqual(FileMode.RegularFile, tw.getFileMode(1));
Assert.AreEqual(cFileId1, tw.getObjectId(0));
Assert.AreEqual(cFileId2, tw.getObjectId(1));
Assert.IsFalse(tw.next());
}