Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index.json in Consolidated zip stores full path, not just hash #1403

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Calamari.ConsolidateCalamariPackages.Tests
[TestFixture]
public class IntegrationTests
{
readonly Assent.Configuration assentConfiguration = new Assent.Configuration().UsingSanitiser(s => Sanitise4PartVersions(SanitiseHashes(s)));
readonly Assent.Configuration assentConfiguration = new Assent.Configuration().UsingSanitiser(s => Sanitise4PartVersions(SanitiseFilenamesInIndex(s)));
static readonly string TestPackagesDirectory = "../../../testPackages";

private string temp;
Expand Down Expand Up @@ -85,7 +85,7 @@ public void AndThenThePackageIsCreated()
public void AndThenThePackageContentsShouldBe()
{
using (var zip = ZipFile.Open(expectedZip, ZipArchiveMode.Read))
this.Assent(string.Join("\r\n", zip.Entries.Select(e => SanitiseHashes(e.FullName)).OrderBy(k => k)), assentConfiguration);
this.Assent(string.Join("\r\n", zip.Entries.Select(e => SanitiseHashesInPackageList(e.FullName)).OrderBy(k => k)), assentConfiguration);
}

public void AndThenTheIndexShouldBe()
Expand All @@ -96,8 +96,12 @@ public void AndThenTheIndexShouldBe()
this.Assent(sr.ReadToEnd(), assentConfiguration);
}

private static string SanitiseHashes(string s)
=> Regex.Replace(s, "[a-z0-9]{32}", "<hash>");
private static string SanitiseFilenamesInIndex(string s)
=> Regex.Replace(s, "[a-z0-9]{32}\\\\[^\"]*", "<hash>");

private static string SanitiseHashesInPackageList(string s)
=> Regex.Replace(s, "[a-z0-9]{32}", "<hash>");


private static string Sanitise4PartVersions(string s)
=> Regex.Replace(s, @"[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+", "<version>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Dictionary<string, string[]> GroupByPlatform(IEnumerable<SourceFile> filesForPac
.GroupBy(f => f.Platform)
.ToDictionary(
g => g.Key,
g => g.Select(f => f.Hash).OrderBy(h => h).ToArray()
g => g.Select(f => Path.Combine(f.Hash, f.FullNameInDestinationArchive.Replace('/', Path.DirectorySeparatorChar))).OrderBy(h => h).ToArray()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should hardcode to use / as it's supported on windows, but \ is not supported on unix-based systems

);

var index = new ConsolidatedPackageIndex(
Expand Down