8000 Fold ObjectDatabaseExtensions.cs into ObjectDatabase.cs · lofcz/libgit2sharp@cacccc2 · GitHub
[go: up one dir, main page]

Skip to content

Commit cacccc2

Browse files
committed
Fold ObjectDatabaseExtensions.cs into ObjectDatabase.cs
1 parent 265a9e9 commit cacccc2

File tree

4 files changed

+32
-43
lines changed

4 files changed

+32
-43
lines changed

LibGit2Sharp.Tests/ArchiveFixture.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ public void ArchivingANullTreeOrCommitThrows()
6868
string path = SandboxBareTestRepo();
6969
using (var repo = new Repository(path))
7070
{
71-
Assert.Throws<ArgumentNullException>(() => repo.ObjectDatabase.Archive((Commit)null, null));
72-
Assert.Throws<ArgumentNullException>(() => repo.ObjectDatabase.Archive((Tree)null, null));
71+
Assert.Throws<ArgumentNullException>(() => repo.ObjectDatabase.Archive(default(Commit), default(ArchiverBase)));
72+
Assert.Throws<ArgumentNullException>(() => repo.ObjectDatabase.Archive(default(Commit), default(string)));
73+
Assert.Throws<ArgumentNullException>(() => repo.ObjectDatabase.Archive(default(Tree), default(ArchiverBase)));
74+
Assert.Throws<ArgumentNullException>(() => repo.ObjectDatabase.Archive(default(Tree), default(string)));
7375
}
7476
}
7577

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@
212212
<Compile Include="SubmoduleUpdate.cs" />
213213
<Compile Include="UnmergedIndexEntriesException.cs" />
214214
<Compile Include="Core\StringExtensions.cs" />
215-
<Compile Include="ObjectDatabaseExtensions.cs" />
216215
<Compile Include="Commit.cs" />
217216
<Compile Include="CommitLog.cs" />
218217
<Compile Include="Configuration.cs" />

LibGit2Sharp/ObjectDatabase.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,34 @@ public virtual TagAnnotation CreateTagAnnotation(string name, GitObject target,
394394
return repo.Lookup<TagAnnotation>(tagId);
395395
}
396396

397+
/// <summary>
398+
/// Create a TAR archive of the given tree.
399+
/// </summary>
400+
/// <param name="tree">The tree.</param>
401+
/// <param name="archivePath">The archive path.</param>
402+
public virtual void Archive(Tree tree, string archivePath)
403+
{
404+
using (var output = new FileStream(archivePath, FileMode.Create))
405+
using (var archiver = new TarArchiver(output))
406+
{
407+
Archive(tree, archiver);
408+
}
409+
}
410+
411+
/// <summary>
412+
/// Create a TAR archive of the given commit.
413+
/// </summary>
414+
/// <param name="commit">commit.</param>
415+
/// <param name="archivePath">The archive path.</param>
416+
public virtual void Archive(Commit commit, string archivePath)
417+
{
418+
using (var output = new FileStream(archivePath, FileMode.Create))
419+
using (var archiver = new TarArchiver(output))
420+
{
421+
Archive(commit, archiver);
422+
}
423+
}
424+
397425
/// <summary>
398426
/// Archive the given commit.
399427
/// </summary>

LibGit2Sharp/ObjectDatabaseExtensions.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0