Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ObjectDatabaseExtensions.cs « LibGit2Sharp - github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1ed70be6cd9b7c29736912f1d423bcd37611a3ae (plain)
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);
            }
        }
    }
}