本文整理汇总了C#中GitSharp.Core.ObjectWriter.WriteBlob方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectWriter.WriteBlob方法的具体用法?C# ObjectWriter.WriteBlob怎么用?C# ObjectWriter.WriteBlob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GitSharp.Core.ObjectWriter
的用法示例。
在下文中一共展示了ObjectWriter.WriteBlob方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: testNonRecursiveFiltering
public void testNonRecursiveFiltering()
{
var ow = new ObjectWriter(db);
ObjectId aSth = ow.WriteBlob("a.sth".getBytes());
ObjectId aTxt = ow.WriteBlob("a.txt".getBytes());
DirCache dc = DirCache.read(db);
DirCacheBuilder builder = dc.builder();
var aSthEntry = new DirCacheEntry("a.sth");
aSthEntry.setFileMode(FileMode.RegularFile);
aSthEntry.setObjectId(aSth);
var aTxtEntry = new DirCacheEntry("a.txt");
aTxtEntry.setFileMode(FileMode.RegularFile);
aTxtEntry.setObjectId(aTxt);
builder.add(aSthEntry);
builder.add(aTxtEntry);
builder.finish();
ObjectId treeId = dc.writeTree(ow);
var tw = new GitSharp.Core.TreeWalk.TreeWalk(db);
tw.setFilter(PathSuffixFilter.create(".txt"));
tw.addTree(treeId);
var paths = new LinkedList<string>();
while (tw.next())
{
paths.AddLast(tw.getPathString());
}
var expected = new LinkedList<string>();
expected.AddLast("a.txt");
Assert.AreEqual(expected, paths);
}
示例2: HashAndInsertObject
public string HashAndInsertObject(Stream file)
{
var writer = new ObjectWriter(_repository);
var objectId = writer.WriteBlob(file.Length, file);
return objectId.ToString();
}
示例3: HashAndInsertObject
public string HashAndInsertObject(Stream file, long length)
{
var writer = new ObjectWriter(_repository);
var objectId = writer.WriteBlob(length, file);
return objectId.Name;
}
示例4: 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());
}
示例5: addFile
private void addFile(Tree t, FileInfo f, ObjectWriter objectWriter)
{
ObjectId id = objectWriter.WriteBlob(f);
t.AddEntry(new FileTreeEntry(t, id, f.Name.getBytes("UTF-8"), false));
}
示例6: HashWithGitSharp
private static string HashWithGitSharp(Stream file)
{
var repository = new Repository(new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, ".git")));
var writer = new ObjectWriter(repository);
return writer.WriteBlob(file.Length, file).ToString();
}
示例7: WriteBlob
private RevObject WriteBlob(Core.Repository repo, string data)
{
var revWalk = new GitSharp.Core.RevWalk.RevWalk(repo);
byte[] bytes = Constants.encode(data);
var ow = new ObjectWriter(repo);
ObjectId id = ow.WriteBlob(bytes);
try
{
Parse(id);
Assert.Fail("Object " + id.Name + " should not exist in test repository");
}
catch (MissingObjectException)
{
// Ok
}
return revWalk.lookupBlob(id);
}
示例8: HashWithGitSharp
private static string HashWithGitSharp(Stream file)
{
var repository = new Repository(new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, GitHelpers.ResolveRepositoryLocation().FullName)));
var writer = new ObjectWriter(repository);
return writer.WriteBlob(file.Length, file).ToString();
}