本文整理汇总了C#中GitSharp.Core.ObjectWriter.WriteTree方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectWriter.WriteTree方法的具体用法?C# ObjectWriter.WriteTree怎么用?C# ObjectWriter.WriteTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GitSharp.Core.ObjectWriter
的用法示例。
在下文中一共展示了ObjectWriter.WriteTree方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 Core.Tree(db);
Core.Tree subA = root.AddTree("sub-a");
subA.AddFile("empty").Id = aFileId;
subA.Id = ow.WriteTree(subA);
Core.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 Core.Tree(db);
Core.Tree subA = root.AddTree("sub-a");
subA.AddFile("empty").Id = aFileId;
subA.Id = ow.WriteTree(subA);
Core.Tree subB = root.AddTree("sub-b");
subB.AddFile("empty").Id = bFileId;
subB.Id = ow.WriteTree(subB);
Core.Tree subC = root.AddTree("sub-c");
subC.AddFile("empty").Id = cFileId2;
subC.Id = ow.WriteTree(subC);
return ow.WriteTree(root);
};
var tw = new GitSharp.Core.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());
}
示例2: testEmptyTreeCorruption
public void testEmptyTreeCorruption()
{
ObjectId bId = ObjectId.FromString("abbbfafe3129f85747aba7bfac992af77134c607");
RevTree tree_root, tree_A, tree_AB;
RevCommit b;
{
global::GitSharp.Core.Tree root = new global::GitSharp.Core.Tree(db);
global::GitSharp.Core.Tree A = root.AddTree("A");
FileTreeEntry B = root.AddFile("B");
B.Id = (bId);
global::GitSharp.Core.Tree A_A = A.AddTree("A");
global::GitSharp.Core.Tree A_B = A.AddTree("B");
var ow = new ObjectWriter(db);
A_A.Id = (ow.WriteTree(A_A));
A_B.Id = (ow.WriteTree(A_B));
A.Id = (ow.WriteTree(A));
root.Id = (ow.WriteTree(root));
tree_root = rw.parseTree(root.Id);
tree_A = rw.parseTree(A.Id);
tree_AB = rw.parseTree(A_A.Id);
Assert.AreSame(tree_AB, rw.parseTree(A_B.Id));
b = Commit(rw.parseTree(root.Id));
}
MarkStart(b);
AssertCommit(b, objw.next());
Assert.IsNull(objw.next());
Assert.AreSame(tree_root, objw.nextObject());
Assert.AreSame(tree_A, objw.nextObject());
Assert.AreSame(tree_AB, objw.nextObject());
Assert.AreSame(rw.lookupBlob(bId), objw.nextObject());
Assert.IsNull(objw.nextObject());
}
示例3: testTwoSuccessiveCommitsLinkedToHead
public void testTwoSuccessiveCommitsLinkedToHead()
{
var repo = createNewEmptyRepo();
var workingDirectory = repo.WorkingDirectory;
repo.Create();
var objectWriter = new ObjectWriter(repo);
FileInfo project1_a_txt = writeTrashFile(Path.Combine(workingDirectory.FullName, "Project-1/A.txt"), "A.txt - first version\n");
FileInfo project1_b_txt = writeTrashFile(Path.Combine(workingDirectory.FullName, "Project-1/B.txt"), "B.txt - first version\n");
var tree = new Tree(repo);
Tree projectTree = tree.AddTree("Project-1");
addFile(projectTree, project1_a_txt, objectWriter);
projectTree.Id = (objectWriter.WriteTree(projectTree));
addFile(projectTree, project1_b_txt, objectWriter);
projectTree.Id = (objectWriter.WriteTree(projectTree));
tree.Id = (objectWriter.WriteTree(tree));
var commit = new Commit(repo)
{
Author = new PersonIdent(jauthor, (0L), 60),
Committer = new PersonIdent(jcommitter, (0L), 60),
Message = "Foo\n\nMessage",
TreeEntry = tree
};
commit.Save();
var commitId = commit.CommitId;
FileInfo project1_b_v2_txt = writeTrashFile(Path.Combine(workingDirectory.FullName, "Project-1/B.txt"), "B.txt - second version\n");
tree = new Tree(repo);
projectTree = tree.AddTree("Project-1");
addFile(projectTree, project1_a_txt, objectWriter);
projectTree.Id = (objectWriter.WriteTree(projectTree));
addFile(projectTree, project1_b_v2_txt, objectWriter);
projectTree.Id = (objectWriter.WriteTree(projectTree));
tree.Id = (objectWriter.WriteTree(tree));
commit = new Commit(repo)
{
Author = new PersonIdent(jauthor, (0L), 60),
Committer = new PersonIdent(jcommitter, (0L), 60),
Message = "Modified",
ParentIds = new[] { commitId },
TreeEntry = tree
};
commit.Save();
commitId = commit.CommitId;
RefUpdate lck = repo.UpdateRef("refs/heads/master");
Assert.IsNotNull(lck, "obtained lock");
lck.NewObjectId = commitId;
Assert.AreEqual(RefUpdate.RefUpdateResult.New, lck.ForceUpdate());
}