forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObjectDatabaseExtensions.cs
40 lines (38 loc) · 1.37 KB
/
ObjectDatabaseExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System.IO;
namespace LibGit2Sharp
{
/// <summary>
/// Provides helper overloads to a <see cref = "ObjectDatabase" />.
/// </summary>
public static class ObjectDatabaseExtensions
{
/// <summary>
/// Create a TAR archive of the given tree.
/// </summary>
/// <param name="odb">The object database.</param>
/// <param name="tree">The tree.</param>
/// <param name="archivePath">The archive path.</param>
public static void Archive(this ObjectDatabase odb, Tree tree, string archivePath)
{
using (var output = new FileStream(archivePath, FileMode.Create))
using (var archiver = new TarArchiver(output))
{
odb.Archive(tree, archiver);
}
}
/// <summary>
/// Create a TAR archive of the given commit.
/// </summary>
/// <param name="odb">The object database.</param>
/// <param name="commit">commit.</param>
/// <param name="archivePath">The archive path.</param>
public static void Archive(this ObjectDatabase odb, Commit commit, string archivePath)
{
using (var output = new FileStream(archivePath, FileMode.Create))
using (var archiver = new TarArchiver(output))
{
odb.Archive(commit, archiver);
}
}
}
}