public static void PreviewSnapshot(PreviewOptions o) { var(_, blobs) = FileFetcher.FindBlobs( o.Files, new Fuzzy( o.ExcludePatterns, FuzzyOption.EmptyMatchesNothing)); if (blobs.Length == 0) { Console.WriteLine("Empty file list. Nothing to do!"); return; } var snapshotStore = CreateSnapshotStore(o.Repository); var snapshotBlobs = snapshotStore.IsEmpty ? Array.Empty <Blob>() : snapshotStore.ShowSnapshot( o.SnapshotId, Fuzzy.MatchAll) .Select(blobReference => blobReference.ToBlob()) .ToArray(); var diff = DiffSet.Create( snapshotBlobs, blobs, blob => blob.Name, (b1, b2) => b1.Equals(b2)); PrintDiff(diff); }
public static void DiffSnapshots(DiffOptions o) { var snapshotStore = CreateSnapshotStore(o.Repository); var diff = DiffSet.Create( snapshotStore.GetSnapshot(o.FirstSnapshotId).BlobReferences, snapshotStore.GetSnapshot(o.SecondSnapshotId).BlobReferences, blobReference => blobReference.Name, (br1, br2) => o.ContentOnly ? br1.ContentUris.SequenceEqual(br2.ContentUris) : br1.Equals(br2)); PrintDiff(diff); }
public static void Create_Shows_Differences_Between_Collections() { var date = DateTime.UtcNow; var nonce = new byte[] { 0xFF }; var first = new[] { new BlobReference( "some blob", date, nonce, new[] { new Uri("some://uri") }), new BlobReference( "changed uri blob", date, nonce, new[] { new Uri("some://uri") }), new BlobReference( "changed date blob", date, nonce, new[] { new Uri("some://uri") }), new BlobReference( "removed blob", date, nonce, new[] { new Uri("some://uri") }) }; var second = new[] { new BlobReference( "some blob", date, nonce, new[] { new Uri("some://uri") }), new BlobReference( "changed uri blob", date, nonce, new[] { new Uri("some://new.uri") }), new BlobReference( "changed date blob", date.AddSeconds(1), nonce, new[] { new Uri("some://uri") }), new BlobReference( "new blob", date, nonce, new[] { new Uri("some://uri") }) }; var expectedDiff = new DiffSet( new[] { "new blob" }, new[] { "changed uri blob", "changed date blob" }, new[] { "removed blob" }); Assert.Equal( expectedDiff, DiffSet.Create( first, second, br => br.Name, (br1, br2) => br1.Equals(br2))); }