blob: a59b2360440ef1fd6c7ca186ae5fc0ac687cff8d (
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
41
42
43
44
45
|
using System;
using System.IO;
using System.Text;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
namespace LibGit2Sharp.Tests
{
public class ArchiveTarFixture : BaseFixture
{
[Fact]
public void CanArchiveACommitWithDirectoryAsTar()
{
var path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
// This tests generates an archive of the bare test repo, and compares it with
// a pre-generated tar file. The expected tar file has been generated with the
// crlf filter active (on windows), so we need to make sure that even if the test
// is launched on linux then the files content has the crlf filter applied (not
// active by default).
var sb = new StringBuilder();
sb.Append("* text eol=crlf\n");
Touch(Path.Combine(repo.Info.Path, "info"), "attributes", sb.ToString());
var commit = repo.Lookup<Commit>("4c062a6361ae6959e06292c1fa5e2822d9c96345");
var scd = BuildSelfCleaningDirectory();
var archivePath = Path.Combine(scd.RootedDirectoryPath, Guid.NewGuid() + ".tar");
Directory.CreateDirectory(scd.RootedDirectoryPath);
repo.ObjectDatabase.Archive(commit, archivePath);
using (var expectedStream = new StreamReader(Path.Combine(ResourcesDirectory.FullName, "expected_archives/commit_with_directory.tar")))
using (var actualStream = new StreamReader(archivePath))
{
string expected = expectedStream.ReadToEnd();
string actual = actualStream.ReadToEnd();
Assert.Equal(expected, actual);
}
}
}
}
}
|