fix(projects): address the line-end review

StillRestores compared the restored version with the new version's parent
as raw text, so a version an older Windows build stored with CRLF never
matched the same choices written as LF, and a commit on a parent already
holding the restored version was labelled a restore. It now compares them
with SameChoices, like every other project text comparison.

The LF line ends of the project writers were only checked through
Environment.NewLine, which is LF on Linux CI already; the tests now assert
the NewLine option of ProjectJson and IndentedJson directly, so reverting
either fails on every OS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-04 23:09:30 +01:00
1 parent 787f030060
commit d2332687da
4 files changed
+34 -2

No files matched your search

@@ -142,6 +142,34 @@ public abstract class WorkspaceMergeTests(TestContext context) : DatabaseTest(co
Assert.Equal(foreign.Id, (await fx.Home.HeadAsync(id, fx.Ct)).Id);
}
[Test]
public async Task ARestoreOfAVersionTheBaseHoldsWithOtherLineEndsIsNoRestore()
{
var fx = await FixtureAsync();
var projects = fx.Archive.Service.Projects;
var main = await projects.MainAsync(fx.Sequence.Id, fx.Ct);
var choices = new ProjectSettings { ExcludedFrames = [1], HeroFrame = 3 };
// A version an older build stored on the other OS, then the same choices as this build writes them (the base).
var foreign = ProjectServiceTests.Foreign(ProjectServiceTests.Draft(await projects.HeadAsync(main.Id, fx.Ct), choices, fx.Frames));
Assert.Equal(PushOutcome.Stored, (await projects.PushAsync(main.Id, foreign, fx.Ct)).Outcome);
var same = ProjectServiceTests.Draft(foreign, choices, fx.Frames);
Assert.NotEqual(foreign.SettingsJson, same.SettingsJson);
Assert.Equal(PushOutcome.Stored, (await projects.PushAsync(main.Id, same, fx.Ct)).Outcome);
var (_, sync) = fx.Workspace();
var project = await fx.CheckoutAsync(sync);
var id = project.ProjectId;
Assert.Equal(same.Id, project.ReadBundle().Workspace!.Base!.VersionId);
// The foreign version restored before a pull moved the base onto the same choices: the restore stays recorded.
await sync.RestoreAsync(id, foreign.Id, fx.Home, fx.Ct);
project.WriteSync(project.ReadSync() with { RestoredFrom = foreign.Id });
// Edited further and saved: the parent already holds the restored version, so the new version is a plain one.
await EditAsync(sync, id, s => s with { Exposure = s.Exposure with { ExposureOffsetEv = 0.4 } }, fx.Ct);
var next = Assert.NotNull(await sync.CommitAsync(id, cancellationToken: fx.Ct));
Assert.Equal((ProjectVersionKind.Commit, (Guid?)null), (next.Kind, next.RestoredFrom));
}
[Test]
public async Task ABaseNamingAPhotoByItsHashReadsAsTheWorkingStateOnMediaThatHaveNotLearntIt()
{